diff --git a/sin-executor/contracts/executionservice/executionservice.abigen.go b/sin-executor/contracts/executionservice/executionservice.abigen.go index d20bc21c46..987921ee9d 100644 --- a/sin-executor/contracts/executionservice/executionservice.abigen.go +++ b/sin-executor/contracts/executionservice/executionservice.abigen.go @@ -3068,7 +3068,7 @@ func (_IGasOracle *IGasOracleCallerSession) EstimateTxCostInRemoteUnits(remoteCh // ISynapseExecutionServiceV1MetaData contains all meta data concerning the ISynapseExecutionServiceV1 contract. var ISynapseExecutionServiceV1MetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", Sigs: map[string]string{ "62014bad": "executorEOA()", "5d62a8dd": "gasOracle()", @@ -3726,8 +3726,8 @@ func (_Initializable *InitializableFilterer) ParseInitialized(log types.Log) (*I // OptionsLibMetaData contains all meta data concerning the OptionsLib contract. var OptionsLibMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122098c6b1c0716cd02d2f7d3144e98d2bcb208bfdafd0b8a5b3826489026072c7e564736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ef4765fee3cfa820e1c89acd7a4e2156cd279f18c23acafb5d7db42b5dd338fb64736f6c63430008140033", } // OptionsLibABI is the input ABI used to generate the binding from. @@ -4597,7 +4597,7 @@ func (_SynapseExecutionServiceEvents *SynapseExecutionServiceEventsFilterer) Par // SynapseExecutionServiceV1MetaData contains all meta data concerning the SynapseExecutionServiceV1 contract. var SynapseExecutionServiceV1MetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", Sigs: map[string]string{ "a217fddf": "DEFAULT_ADMIN_ROLE()", "ccc57490": "GOVERNOR_ROLE()", @@ -4618,7 +4618,7 @@ var SynapseExecutionServiceV1MetaData = &bind.MetaData{ "cf4f578f": "setGlobalMarkup(uint256)", "01ffc9a7": "supportsInterface(bytes4)", }, - Bin: "0x608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6114fe806100df6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e610149366004611082565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a63660046110cb565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e836600461110d565b610476565b005b6101ed6101fd366004611128565b610587565b6101ed610210366004611128565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be366004611128565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b36600461110d565b61062f565b61018a61033e36600461126e565b61075a565b6101ed61035136600461110d565b610a03565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b3660046110cb565b610b86565b6101ed61039e366004611128565b610c26565b6101ed6103b13660046112be565b610c6a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d25565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d25565b6105cb8383610d32565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e53565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d25565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f584610f31565b509050600160ff82161115610840576040517fdaa5a14f00000000000000000000000000000000000000000000000000000000815260ff821660048201526024015b60405180910390fd5b600061084b85610f53565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091526044810188905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190611322565b6020820151909450156109a95760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b92879161095b918b91600401918252602082015260400190565b602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611322565b6109a6908561136a565b93505b670de0b6b3a76400006109da7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b6109e4908661137d565b6109ee9190611394565b6109f8908561136a565b979650505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a4e5750825b905060008267ffffffffffffffff166001148015610a6b5750303b155b905081158015610a79575080155b15610ab0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b115784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b1c600087610d32565b508315610b7e5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610bb081610d25565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c6081610d25565b6105cb8383610e53565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610c9481610d25565b6000610ca187878561075a565b905080841015610ce7576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610837565b60405133815285907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a250505050505050565b610d2f8133610fd7565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610de53390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b6000606082806020019051810190610f4991906113cf565b9094909350915050565b6040805180820190915260008082526020820152600080610f7384610f31565b9092509050600160ff83161015610fbb576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff83166004820152602401610837565b80806020019051810190610fcf9190611479565b949350505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661107e576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610837565b5050565b60006020828403121561109457600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c457600080fd5b9392505050565b6000602082840312156110dd57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461110857600080fd5b919050565b60006020828403121561111f57600080fd5b6110c4826110e4565b6000806040838503121561113b57600080fd5b8235915061114b602084016110e4565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111ca576111ca611154565b604052919050565b600067ffffffffffffffff8211156111ec576111ec611154565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261122957600080fd5b813561123c611237826111d2565b611183565b81815284602083860101111561125157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561128357600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156112a857600080fd5b6112b486828701611218565b9150509250925092565b600080600080600060a086880312156112d657600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561130957600080fd5b61131588828901611218565b9150509295509295909350565b60006020828403121561133457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104705761047061133b565b80820281158282048414176104705761047061133b565b6000826113ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600080604083850312156113e257600080fd5b825160ff811681146113f357600080fd5b8092505060208084015167ffffffffffffffff81111561141257600080fd5b8401601f8101861361142357600080fd5b8051611431611237826111d2565b818152878483850101111561144557600080fd5b60005b82811015611463578381018501518282018601528401611448565b5060009181019093015250919491935090915050565b60006040828403121561148b57600080fd5b6040516040810181811067ffffffffffffffff821117156114ae576114ae611154565b60405282518152602092830151928101929092525091905056fea2646970667358221220372fc3746b9ff8ba16657a8bb619d07d869c044f1b63406c5221adea75c6096d64736f6c63430008140033", + Bin: "0x608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b611641806100df6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e61014936600461122f565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a6366004611271565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e83660046112b3565b610476565b005b6101ed6101fd3660046112ce565b610587565b6101ed6102103660046112ce565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be3660046112ce565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b3660046112b3565b61062f565b61018a61033e366004611343565b61075a565b6101ed6103513660046112b3565b610a3c565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b366004611271565b610bbf565b6101ed61039e3660046112ce565b610c5f565b6101ed6103b1366004611396565b610ca3565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d60565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d60565b6105cb8383610d6d565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e8e565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d60565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f68585610f6c565b9050600161ffff82161115610842576040517f05e98f3a00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b600061088386868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610fb692505050565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018b905260248101919091526044810189905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190611400565b6020820151909450156109e15760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b928791610993918c91600401918252602082015260400190565b602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611400565b6109de9085611448565b93505b670de0b6b3a7640000610a127fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b610a1c908661145b565b610a269190611472565b610a309085611448565b98975050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a875750825b905060008267ffffffffffffffff166001148015610aa45750303b155b905081158015610ab2575080155b15610ae9576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b4a5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b55600087610d6d565b508315610bb75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610be981610d60565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c9981610d60565b6105cb8383610e8e565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610ccd81610d60565b6000610cdb8888868661075a565b905080851015610d21576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610839565b60405133815286907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a25050505050505050565b610d6a813361103f565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610e203390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b60006002821015610fad5782826040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016108399291906114ad565b50503560f01c90565b60408051808201909152600080825260208201526000610fd5836110ea565b9050600161ffff8216101561101c576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff82166004820152602401610839565b61102583611135565b8060200190518101906110389190611529565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110e6576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610839565b5050565b600060028251101561112a57816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b506020015160f01c90565b606060028251101561117557816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156111b2576111b26114fa565b6040519080825280601f01601f1916602001820160405280156111dc576020820181803683370190505b50915060008160208401836022870160045afa905080611228576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561124157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461103857600080fd5b60006020828403121561128357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112ae57600080fd5b919050565b6000602082840312156112c557600080fd5b6110388261128a565b600080604083850312156112e157600080fd5b823591506112f16020840161128a565b90509250929050565b60008083601f84011261130c57600080fd5b50813567ffffffffffffffff81111561132457600080fd5b60208301915083602082850101111561133c57600080fd5b9250929050565b6000806000806060858703121561135957600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561137e57600080fd5b61138a878288016112fa565b95989497509550505050565b60008060008060008060a087890312156113af57600080fd5b86359550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156113e257600080fd5b6113ee89828a016112fa565b979a9699509497509295939492505050565b60006020828403121561141257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047057610470611419565b808202811582820484141761047057610470611419565b6000826114a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006040828403121561153b57600080fd5b6040516040810181811067ffffffffffffffff82111715611585577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b600060208083528351808285015260005b818110156115cc578581018301518582016040015282016115b0565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509291505056fea264697066735822122073ac682035a1c9af569f83acef83df3f74f4bfc62dfd61335eaf24679880326e64736f6c63430008140033", } // SynapseExecutionServiceV1ABI is the input ABI used to generate the binding from. @@ -6439,7 +6439,7 @@ func (_SynapseExecutionServiceV1 *SynapseExecutionServiceV1Filterer) ParseRoleRe // SynapseExecutionServiceV1HarnessMetaData contains all meta data concerning the SynapseExecutionServiceV1Harness contract. var SynapseExecutionServiceV1HarnessMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", Sigs: map[string]string{ "a217fddf": "DEFAULT_ADMIN_ROLE()", "ccc57490": "GOVERNOR_ROLE()", @@ -6460,7 +6460,7 @@ var SynapseExecutionServiceV1HarnessMetaData = &bind.MetaData{ "cf4f578f": "setGlobalMarkup(uint256)", "01ffc9a7": "supportsInterface(bytes4)", }, - Bin: "0x608060405234801561001057600080fd5b5061001c60003361004d565b506100477f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f553361004d565b5061011e565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16610112576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556100c83390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610118565b60009150505b92915050565b6114fe8061012d6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e610149366004611082565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a63660046110cb565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e836600461110d565b610476565b005b6101ed6101fd366004611128565b610587565b6101ed610210366004611128565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be366004611128565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b36600461110d565b61062f565b61018a61033e36600461126e565b61075a565b6101ed61035136600461110d565b610a03565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b3660046110cb565b610b86565b6101ed61039e366004611128565b610c26565b6101ed6103b13660046112be565b610c6a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d25565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d25565b6105cb8383610d32565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e53565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d25565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f584610f31565b509050600160ff82161115610840576040517fdaa5a14f00000000000000000000000000000000000000000000000000000000815260ff821660048201526024015b60405180910390fd5b600061084b85610f53565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091526044810188905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190611322565b6020820151909450156109a95760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b92879161095b918b91600401918252602082015260400190565b602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611322565b6109a6908561136a565b93505b670de0b6b3a76400006109da7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b6109e4908661137d565b6109ee9190611394565b6109f8908561136a565b979650505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a4e5750825b905060008267ffffffffffffffff166001148015610a6b5750303b155b905081158015610a79575080155b15610ab0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b115784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b1c600087610d32565b508315610b7e5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610bb081610d25565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c6081610d25565b6105cb8383610e53565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610c9481610d25565b6000610ca187878561075a565b905080841015610ce7576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610837565b60405133815285907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a250505050505050565b610d2f8133610fd7565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610de53390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b6000606082806020019051810190610f4991906113cf565b9094909350915050565b6040805180820190915260008082526020820152600080610f7384610f31565b9092509050600160ff83161015610fbb576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff83166004820152602401610837565b80806020019051810190610fcf9190611479565b949350505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661107e576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610837565b5050565b60006020828403121561109457600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c457600080fd5b9392505050565b6000602082840312156110dd57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461110857600080fd5b919050565b60006020828403121561111f57600080fd5b6110c4826110e4565b6000806040838503121561113b57600080fd5b8235915061114b602084016110e4565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111ca576111ca611154565b604052919050565b600067ffffffffffffffff8211156111ec576111ec611154565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261122957600080fd5b813561123c611237826111d2565b611183565b81815284602083860101111561125157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561128357600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156112a857600080fd5b6112b486828701611218565b9150509250925092565b600080600080600060a086880312156112d657600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561130957600080fd5b61131588828901611218565b9150509295509295909350565b60006020828403121561133457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104705761047061133b565b80820281158282048414176104705761047061133b565b6000826113ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600080604083850312156113e257600080fd5b825160ff811681146113f357600080fd5b8092505060208084015167ffffffffffffffff81111561141257600080fd5b8401601f8101861361142357600080fd5b8051611431611237826111d2565b818152878483850101111561144557600080fd5b60005b82811015611463578381018501518282018601528401611448565b5060009181019093015250919491935090915050565b60006040828403121561148b57600080fd5b6040516040810181811067ffffffffffffffff821117156114ae576114ae611154565b60405282518152602092830151928101929092525091905056fea26469706673582212204d9603c91ccf537ac623341f0d5212043f170827bd01b4adbdf6152bb060fd1f64736f6c63430008140033", + Bin: "0x608060405234801561001057600080fd5b5061001c60003361004d565b506100477f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f553361004d565b5061011e565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16610112576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556100c83390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610118565b60009150505b92915050565b6116418061012d6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e61014936600461122f565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a6366004611271565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e83660046112b3565b610476565b005b6101ed6101fd3660046112ce565b610587565b6101ed6102103660046112ce565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be3660046112ce565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b3660046112b3565b61062f565b61018a61033e366004611343565b61075a565b6101ed6103513660046112b3565b610a3c565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b366004611271565b610bbf565b6101ed61039e3660046112ce565b610c5f565b6101ed6103b1366004611396565b610ca3565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d60565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d60565b6105cb8383610d6d565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e8e565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d60565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f68585610f6c565b9050600161ffff82161115610842576040517f05e98f3a00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b600061088386868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610fb692505050565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018b905260248101919091526044810189905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190611400565b6020820151909450156109e15760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b928791610993918c91600401918252602082015260400190565b602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611400565b6109de9085611448565b93505b670de0b6b3a7640000610a127fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b610a1c908661145b565b610a269190611472565b610a309085611448565b98975050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a875750825b905060008267ffffffffffffffff166001148015610aa45750303b155b905081158015610ab2575080155b15610ae9576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b4a5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b55600087610d6d565b508315610bb75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610be981610d60565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c9981610d60565b6105cb8383610e8e565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610ccd81610d60565b6000610cdb8888868661075a565b905080851015610d21576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610839565b60405133815286907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a25050505050505050565b610d6a813361103f565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610e203390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b60006002821015610fad5782826040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016108399291906114ad565b50503560f01c90565b60408051808201909152600080825260208201526000610fd5836110ea565b9050600161ffff8216101561101c576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff82166004820152602401610839565b61102583611135565b8060200190518101906110389190611529565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110e6576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610839565b5050565b600060028251101561112a57816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b506020015160f01c90565b606060028251101561117557816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156111b2576111b26114fa565b6040519080825280601f01601f1916602001820160405280156111dc576020820181803683370190505b50915060008160208401836022870160045afa905080611228576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561124157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461103857600080fd5b60006020828403121561128357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112ae57600080fd5b919050565b6000602082840312156112c557600080fd5b6110388261128a565b600080604083850312156112e157600080fd5b823591506112f16020840161128a565b90509250929050565b60008083601f84011261130c57600080fd5b50813567ffffffffffffffff81111561132457600080fd5b60208301915083602082850101111561133c57600080fd5b9250929050565b6000806000806060858703121561135957600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561137e57600080fd5b61138a878288016112fa565b95989497509550505050565b60008060008060008060a087890312156113af57600080fd5b86359550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156113e257600080fd5b6113ee89828a016112fa565b979a9699509497509295939492505050565b60006020828403121561141257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047057610470611419565b808202811582820484141761047057610470611419565b6000826114a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006040828403121561153b57600080fd5b6040516040810181811067ffffffffffffffff82111715611585577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b600060208083528351808285015260005b818110156115cc578581018301518582016040015282016115b0565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509291505056fea264697066735822122038f9f03f552b59eeabda9f604e46cf730b047f7ac321a71a3a6ef7a07151b77964736f6c63430008140033", } // SynapseExecutionServiceV1HarnessABI is the input ABI used to generate the binding from. @@ -8278,3 +8278,176 @@ func (_SynapseExecutionServiceV1Harness *SynapseExecutionServiceV1HarnessFiltere event.Raw = log return event, nil } + +// VersionedPayloadLibMetaData contains all meta data concerning the VersionedPayloadLib contract. +var VersionedPayloadLibMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122023cca83e88122e438334a2396d46ea948ce2e2e8150ba7b4a02e1b952f2655fb64736f6c63430008140033", +} + +// VersionedPayloadLibABI is the input ABI used to generate the binding from. +// Deprecated: Use VersionedPayloadLibMetaData.ABI instead. +var VersionedPayloadLibABI = VersionedPayloadLibMetaData.ABI + +// VersionedPayloadLibBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use VersionedPayloadLibMetaData.Bin instead. +var VersionedPayloadLibBin = VersionedPayloadLibMetaData.Bin + +// DeployVersionedPayloadLib deploys a new Ethereum contract, binding an instance of VersionedPayloadLib to it. +func DeployVersionedPayloadLib(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *VersionedPayloadLib, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(VersionedPayloadLibBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// VersionedPayloadLib is an auto generated Go binding around an Ethereum contract. +type VersionedPayloadLib struct { + VersionedPayloadLibCaller // Read-only binding to the contract + VersionedPayloadLibTransactor // Write-only binding to the contract + VersionedPayloadLibFilterer // Log filterer for contract events +} + +// VersionedPayloadLibCaller is an auto generated read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibTransactor is an auto generated write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type VersionedPayloadLibFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type VersionedPayloadLibSession struct { + Contract *VersionedPayloadLib // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type VersionedPayloadLibCallerSession struct { + Contract *VersionedPayloadLibCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// VersionedPayloadLibTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type VersionedPayloadLibTransactorSession struct { + Contract *VersionedPayloadLibTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibRaw is an auto generated low-level Go binding around an Ethereum contract. +type VersionedPayloadLibRaw struct { + Contract *VersionedPayloadLib // Generic contract binding to access the raw methods on +} + +// VersionedPayloadLibCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCallerRaw struct { + Contract *VersionedPayloadLibCaller // Generic read-only contract binding to access the raw methods on +} + +// VersionedPayloadLibTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactorRaw struct { + Contract *VersionedPayloadLibTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewVersionedPayloadLib creates a new instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLib(address common.Address, backend bind.ContractBackend) (*VersionedPayloadLib, error) { + contract, err := bindVersionedPayloadLib(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// NewVersionedPayloadLibCaller creates a new read-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibCaller(address common.Address, caller bind.ContractCaller) (*VersionedPayloadLibCaller, error) { + contract, err := bindVersionedPayloadLib(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibCaller{contract: contract}, nil +} + +// NewVersionedPayloadLibTransactor creates a new write-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibTransactor(address common.Address, transactor bind.ContractTransactor) (*VersionedPayloadLibTransactor, error) { + contract, err := bindVersionedPayloadLib(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibTransactor{contract: contract}, nil +} + +// NewVersionedPayloadLibFilterer creates a new log filterer instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibFilterer(address common.Address, filterer bind.ContractFilterer) (*VersionedPayloadLibFilterer, error) { + contract, err := bindVersionedPayloadLib(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &VersionedPayloadLibFilterer{contract: contract}, nil +} + +// bindVersionedPayloadLib binds a generic wrapper to an already deployed contract. +func bindVersionedPayloadLib(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.VersionedPayloadLibCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transact(opts, method, params...) +} diff --git a/sin-executor/contracts/executionservice/executionservice.contractinfo.json b/sin-executor/contracts/executionservice/executionservice.contractinfo.json index 96000e2418..1bb74e62f4 100644 --- a/sin-executor/contracts/executionservice/executionservice.contractinfo.json +++ b/sin-executor/contracts/executionservice/executionservice.contractinfo.json @@ -1 +1 @@ -{"solidity/SynapseExecutionServiceV1Harness.sol:AccessControlUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."},"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"AccessControlUpgradeable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:ContextUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","errors":{"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"}],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"errors\":{\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"ContextUpgradeable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:ERC165Upgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```","errors":{"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```\",\"errors\":{\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"ERC165Upgradeable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:IAccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"External interface of AccessControl declared to support ERC165 detection.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"External interface of AccessControl declared to support ERC165 detection.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IAccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"solidity/SynapseExecutionServiceV1Harness.sol:IERC165":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.","kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.\",\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IERC165\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:IExecutionService":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IExecutionService\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"executorEOA()":"62014bad","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522"}},"solidity/SynapseExecutionServiceV1Harness.sol:IGasOracle":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"remoteChainId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"convertRemoteValueToLocalUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"remoteChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"calldataSize","type":"uint256"}],"name":"estimateTxCostInLocalUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"remoteChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"calldataSize","type":"uint256"}],"name":"estimateTxCostInRemoteUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"convertRemoteValueToLocalUnits(uint256,uint256)":{"notice":"Convert a value from the native token of a remote chain to the local native token."},"estimateTxCostInLocalUnits(uint256,uint256,uint256)":{"notice":"Estimate the cost of execution a transaction on a remote chain, and convert it to the local native token."},"estimateTxCostInRemoteUnits(uint256,uint256,uint256)":{"notice":"Estimate the cost of execution a transaction on a remote chain, and return it as is in the remote chain's native token."}},"version":1},"developerDoc":{"kind":"dev","methods":{"convertRemoteValueToLocalUnits(uint256,uint256)":{"details":"Will revert if no price is available for the remote chain.","params":{"remoteChainId":"The chain id of the remote chain.","value":"The value to convert."}},"estimateTxCostInLocalUnits(uint256,uint256,uint256)":{"details":"Will revert if no price is available for the remote chain.","params":{"calldataSize":"The size of the transaction calldata.","gasLimit":"The gas limit of the transaction.","remoteChainId":"The chain id of the remote chain."}},"estimateTxCostInRemoteUnits(uint256,uint256,uint256)":{"details":"Will revert if no price is available for the remote chain.","params":{"calldataSize":"The size of the transaction calldata.","gasLimit":"The gas limit of the transaction.","remoteChainId":"The chain id of the remote chain."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"remoteChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"convertRemoteValueToLocalUnits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"remoteChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"calldataSize\",\"type\":\"uint256\"}],\"name\":\"estimateTxCostInLocalUnits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"remoteChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"calldataSize\",\"type\":\"uint256\"}],\"name\":\"estimateTxCostInRemoteUnits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"convertRemoteValueToLocalUnits(uint256,uint256)\":{\"details\":\"Will revert if no price is available for the remote chain.\",\"params\":{\"remoteChainId\":\"The chain id of the remote chain.\",\"value\":\"The value to convert.\"}},\"estimateTxCostInLocalUnits(uint256,uint256,uint256)\":{\"details\":\"Will revert if no price is available for the remote chain.\",\"params\":{\"calldataSize\":\"The size of the transaction calldata.\",\"gasLimit\":\"The gas limit of the transaction.\",\"remoteChainId\":\"The chain id of the remote chain.\"}},\"estimateTxCostInRemoteUnits(uint256,uint256,uint256)\":{\"details\":\"Will revert if no price is available for the remote chain.\",\"params\":{\"calldataSize\":\"The size of the transaction calldata.\",\"gasLimit\":\"The gas limit of the transaction.\",\"remoteChainId\":\"The chain id of the remote chain.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"convertRemoteValueToLocalUnits(uint256,uint256)\":{\"notice\":\"Convert a value from the native token of a remote chain to the local native token.\"},\"estimateTxCostInLocalUnits(uint256,uint256,uint256)\":{\"notice\":\"Estimate the cost of execution a transaction on a remote chain, and convert it to the local native token.\"},\"estimateTxCostInRemoteUnits(uint256,uint256,uint256)\":{\"notice\":\"Estimate the cost of execution a transaction on a remote chain, and return it as is in the remote chain's native token.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IGasOracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"convertRemoteValueToLocalUnits(uint256,uint256)":"1e7b9287","estimateTxCostInLocalUnits(uint256,uint256,uint256)":"5cbd3c48","estimateTxCostInRemoteUnits(uint256,uint256,uint256)":"fd6a7167"}},"solidity/SynapseExecutionServiceV1Harness.sol:ISynapseExecutionServiceV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"SynapseExecutionService__FeeAmountTooLow","type":"error"},{"inputs":[],"name":"SynapseExecutionService__GasOracleNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"}],"name":"SynapseExecutionService__OptionsVersionNotSupported","type":"error"},{"inputs":[],"name":"SynapseExecutionService__ZeroAddress","type":"error"},{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalMarkup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executorEOA_","type":"address"}],"name":"setExecutorEOA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"globalMarkup_","type":"uint256"}],"name":"setGlobalMarkup","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"gasOracle()":{"notice":"Address of the gas oracle used for estimating the gas cost of the transactions."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"globalMarkup()":{"notice":"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."},"setExecutorEOA(address)":{"notice":"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains."},"setGasOracle(address)":{"notice":"Allows the contract governor to set the address of the gas oracle."},"setGlobalMarkup(uint256)":{"notice":"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"gasOracle()\":{\"notice\":\"Address of the gas oracle used for estimating the gas cost of the transactions.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"globalMarkup()\":{\"notice\":\"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"},\"setExecutorEOA(address)\":{\"notice\":\"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"setGasOracle(address)\":{\"notice\":\"Allows the contract governor to set the address of the gas oracle.\"},\"setGlobalMarkup(uint256)\":{\"notice\":\"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"ISynapseExecutionServiceV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"executorEOA()":"62014bad","gasOracle()":"5d62a8dd","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","globalMarkup()":"efd07ec2","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522","setExecutorEOA(address)":"2d54566c","setGasOracle(address)":"a87b8152","setGlobalMarkup(uint256)":"cf4f578f"}},"solidity/SynapseExecutionServiceV1Harness.sol:Initializable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"custom:oz-upgrades-unsafe-allow":"constructor constructor() { _disableInitializers(); } ``` ====","details":"This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in case an upgrade adds a module that needs to be initialized. For example: [.hljs-theme-light.nopadding] ```solidity contract MyToken is ERC20Upgradeable { function initialize() initializer public { __ERC20_init(\"MyToken\", \"MTK\"); } } contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { function initializeV2() reinitializer(2) public { __ERC20Permit_init(\"MyToken\"); } } ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding] ```","errors":{"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"}],\"devdoc\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor constructor() { _disableInitializers(); } ``` ====\",\"details\":\"This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in case an upgrade adds a module that needs to be initialized. For example: [.hljs-theme-light.nopadding] ```solidity contract MyToken is ERC20Upgradeable { function initialize() initializer public { __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\"); } } contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { function initializeV2() reinitializer(2) public { __ERC20Permit_init(\\\"MyToken\\\"); } } ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding] ```\",\"errors\":{\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"Initializable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122098c6b1c0716cd02d2f7d3144e98d2bcb208bfdafd0b8a5b3826489026072c7e564736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122098c6b1c0716cd02d2f7d3144e98d2bcb208bfdafd0b8a5b3826489026072c7e564736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"4646:1958:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;4646:1958:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"4646:1958:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:SynapseExecutionServiceEvents":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"ExecutionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executorEOA","type":"address"}],"name":"ExecutorEOASet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gasOracle","type":"address"}],"name":"GasOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalMarkup","type":"uint256"}],"name":"GlobalMarkupSet","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"SynapseExecutionServiceEvents\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:SynapseExecutionServiceV1":{"code":"0x608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6114fe806100df6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e610149366004611082565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a63660046110cb565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e836600461110d565b610476565b005b6101ed6101fd366004611128565b610587565b6101ed610210366004611128565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be366004611128565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b36600461110d565b61062f565b61018a61033e36600461126e565b61075a565b6101ed61035136600461110d565b610a03565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b3660046110cb565b610b86565b6101ed61039e366004611128565b610c26565b6101ed6103b13660046112be565b610c6a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d25565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d25565b6105cb8383610d32565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e53565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d25565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f584610f31565b509050600160ff82161115610840576040517fdaa5a14f00000000000000000000000000000000000000000000000000000000815260ff821660048201526024015b60405180910390fd5b600061084b85610f53565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091526044810188905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190611322565b6020820151909450156109a95760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b92879161095b918b91600401918252602082015260400190565b602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611322565b6109a6908561136a565b93505b670de0b6b3a76400006109da7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b6109e4908661137d565b6109ee9190611394565b6109f8908561136a565b979650505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a4e5750825b905060008267ffffffffffffffff166001148015610a6b5750303b155b905081158015610a79575080155b15610ab0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b115784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b1c600087610d32565b508315610b7e5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610bb081610d25565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c6081610d25565b6105cb8383610e53565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610c9481610d25565b6000610ca187878561075a565b905080841015610ce7576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610837565b60405133815285907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a250505050505050565b610d2f8133610fd7565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610de53390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b6000606082806020019051810190610f4991906113cf565b9094909350915050565b6040805180820190915260008082526020820152600080610f7384610f31565b9092509050600160ff83161015610fbb576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff83166004820152602401610837565b80806020019051810190610fcf9190611479565b949350505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661107e576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610837565b5050565b60006020828403121561109457600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c457600080fd5b9392505050565b6000602082840312156110dd57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461110857600080fd5b919050565b60006020828403121561111f57600080fd5b6110c4826110e4565b6000806040838503121561113b57600080fd5b8235915061114b602084016110e4565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111ca576111ca611154565b604052919050565b600067ffffffffffffffff8211156111ec576111ec611154565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261122957600080fd5b813561123c611237826111d2565b611183565b81815284602083860101111561125157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561128357600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156112a857600080fd5b6112b486828701611218565b9150509250925092565b600080600080600060a086880312156112d657600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561130957600080fd5b61131588828901611218565b9150509295509295909350565b60006020828403121561133457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104705761047061133b565b80820281158282048414176104705761047061133b565b6000826113ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600080604083850312156113e257600080fd5b825160ff811681146113f357600080fd5b8092505060208084015167ffffffffffffffff81111561141257600080fd5b8401601f8101861361142357600080fd5b8051611431611237826111d2565b818152878483850101111561144557600080fd5b60005b82811015611463578381018501518282018601528401611448565b5060009181019093015250919491935090915050565b60006040828403121561148b57600080fd5b6040516040810181811067ffffffffffffffff821117156114ae576114ae611154565b60405282518152602092830151928101929092525091905056fea2646970667358221220372fc3746b9ff8ba16657a8bb619d07d869c044f1b63406c5221adea75c6096d64736f6c63430008140033","runtime-code":"0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e610149366004611082565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a63660046110cb565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e836600461110d565b610476565b005b6101ed6101fd366004611128565b610587565b6101ed610210366004611128565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be366004611128565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b36600461110d565b61062f565b61018a61033e36600461126e565b61075a565b6101ed61035136600461110d565b610a03565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b3660046110cb565b610b86565b6101ed61039e366004611128565b610c26565b6101ed6103b13660046112be565b610c6a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d25565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d25565b6105cb8383610d32565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e53565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d25565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f584610f31565b509050600160ff82161115610840576040517fdaa5a14f00000000000000000000000000000000000000000000000000000000815260ff821660048201526024015b60405180910390fd5b600061084b85610f53565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091526044810188905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190611322565b6020820151909450156109a95760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b92879161095b918b91600401918252602082015260400190565b602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611322565b6109a6908561136a565b93505b670de0b6b3a76400006109da7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b6109e4908661137d565b6109ee9190611394565b6109f8908561136a565b979650505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a4e5750825b905060008267ffffffffffffffff166001148015610a6b5750303b155b905081158015610a79575080155b15610ab0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b115784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b1c600087610d32565b508315610b7e5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610bb081610d25565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c6081610d25565b6105cb8383610e53565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610c9481610d25565b6000610ca187878561075a565b905080841015610ce7576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610837565b60405133815285907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a250505050505050565b610d2f8133610fd7565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610de53390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b6000606082806020019051810190610f4991906113cf565b9094909350915050565b6040805180820190915260008082526020820152600080610f7384610f31565b9092509050600160ff83161015610fbb576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff83166004820152602401610837565b80806020019051810190610fcf9190611479565b949350505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661107e576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610837565b5050565b60006020828403121561109457600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c457600080fd5b9392505050565b6000602082840312156110dd57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461110857600080fd5b919050565b60006020828403121561111f57600080fd5b6110c4826110e4565b6000806040838503121561113b57600080fd5b8235915061114b602084016110e4565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111ca576111ca611154565b604052919050565b600067ffffffffffffffff8211156111ec576111ec611154565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261122957600080fd5b813561123c611237826111d2565b611183565b81815284602083860101111561125157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561128357600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156112a857600080fd5b6112b486828701611218565b9150509250925092565b600080600080600060a086880312156112d657600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561130957600080fd5b61131588828901611218565b9150509295509295909350565b60006020828403121561133457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104705761047061133b565b80820281158282048414176104705761047061133b565b6000826113ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600080604083850312156113e257600080fd5b825160ff811681146113f357600080fd5b8092505060208084015167ffffffffffffffff81111561141257600080fd5b8401601f8101861361142357600080fd5b8051611431611237826111d2565b818152878483850101111561144557600080fd5b60005b82811015611463578381018501518282018601528401611448565b5060009181019093015250919491935090915050565b60006040828403121561148b57600080fd5b6040516040810181811067ffffffffffffffff821117156114ae576114ae611154565b60405282518152602092830151928101929092525091905056fea2646970667358221220372fc3746b9ff8ba16657a8bb619d07d869c044f1b63406c5221adea75c6096d64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"31455:5192:0:-:0;;;32260:129;;;;;;;;;-1:-1:-1;32360:22:0;:20;:22::i;:::-;31455:5192;;18496:422;19655:21;18685:15;;;;;;;18681:76;;;18723:23;;-1:-1:-1;;;18723:23:0;;;;;;;;;;;18681:76;18770:14;;-1:-1:-1;;;;;18770:14:0;;;:34;18766:146;;18820:33;;-1:-1:-1;;;;;;18820:33:0;-1:-1:-1;;;;;18820:33:0;;;;;18872:29;;158:50:1;;;18872:29:0;;146:2:1;131:18;18872:29:0;;;;;;;18766:146;18545:373;18496:422::o;14:200:1:-;31455:5192:0;;;;;;","srcMapRuntime":"31455:5192:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26560:202;;;;;;:::i;:::-;;:::i;:::-;;;516:14:1;;509:22;491:41;;479:2;464:18;26560:202:0;;;;;;;;32185:68;;32226:27;32185:68;;;;;689:25:1;;;677:2;662:18;32185:68:0;543:177:1;27876:191:0;;;;;;:::i;:::-;27941:7;28036:14;;;26037:28;28036:14;;;;;:24;;;;27876:191;32566:379;;;;;;:::i;:::-;;:::i;:::-;;28363:136;;;;;;:::i;:::-;;:::i;29465:245::-;;;;;;:::i;:::-;;:::i;35896:187::-;36065:11;;;;35896:187;;;1737:42:1;1725:55;;;1707:74;;1695:2;1680:18;35896:187:0;1561:226:1;35652:191:0;36584:45;35823:13;;;35652:191;;26849:207;;;;;;:::i;:::-;26926:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;;;;26849:207;25435:49;;25480:4;25435:49;;32998:365;;;;;;:::i;:::-;;:::i;34365:1243::-;;;;;;:::i;:::-;;:::i;32395:118::-;;;;;;:::i;:::-;;:::i;32113:66::-;;32153:26;32113:66;;33416:274;;;;;;:::i;:::-;;:::i;28779:138::-;;;;;;:::i;:::-;;:::i;33734:587::-;;;;;;:::i;:::-;;:::i;36136:193::-;36308:14;;36136:193;;26560:202;26645:4;26668:47;;;26683:32;26668:47;;:87;;-1:-1:-1;23346:25:0;23331:40;;;;26719:36;26661:94;26560:202;-1:-1:-1;;26560:202:0:o;32566:379::-;32153:26;26308:16;26319:4;26308:10;:16::i;:::-;32667:26:::1;::::0;::::1;32663:102;;32716:38;;;;;;;;;;;;;;32663:102;36584:45:::0;32867:28;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;32910::::1;::::0;1707:74:1;;;32910:28:0::1;::::0;1695:2:1;1680:18;32910:28:0::1;;;;;;;;32653:292;32566:379:::0;;:::o;28363:136::-;27941:7;28036:14;;;26037:28;28036:14;;;;;:24;;;26308:16;26319:4;26308:10;:16::i;:::-;28467:25:::1;28478:4;28484:7;28467:10;:25::i;:::-;;28363:136:::0;;;:::o;29465:245::-;29558:34;;;22081:10;29558:34;29554:102;;29615:30;;;;;;;;;;;;;;29554:102;29666:37;29678:4;29684:18;29666:11;:37::i;:::-;;29465:245;;:::o;32998:365::-;32153:26;26308:16;26319:4;26308:10;:16::i;:::-;33095:24:::1;::::0;::::1;33091:100;;33142:38;;;;;;;;;;;;;;33091:100;33293:11:::0;:24;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;33332::::1;::::0;1707:74:1;;;36584:45:0;;33332:24:::1;::::0;1695:2:1;1680:18;33332:24:0::1;1561:226:1::0;34365:1243:0;34546:20;34582:23;34608:11;36065;;;;;35896:187;34608:11;34582:37;-1:-1:-1;34633:29:0;;;34629:109;;34685:42;;;;;;;;;;;;;;34629:109;34813:13;34831:42;34865:7;34831:33;:42::i;:::-;-1:-1:-1;34812:61:0;-1:-1:-1;4699:1:0;34887:31;;;;34883:129;;;34941:60;;;;;4638:4:1;4626:17;;34941:60:0;;;4608:36:1;4581:18;;34941:60:0;;;;;;;;34883:129;35021:26;35050:35;35077:7;35050:26;:35::i;:::-;35228:18;;35110:188;;;;;;;;4857:25:1;;;4898:18;;;4891:34;;;;4941:18;;;4934:34;;;35228:18:0;;-1:-1:-1;35110:54:0;;;;;;4830:18:1;;35110:188:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;35312:20;;;;35095:203;;-1:-1:-1;35312:24:0;35308:233;;35495:20;;;;35368:162;;;;;:58;;;;;;:162;;35460:10;;35368:162;;5342:25:1;;;5398:2;5383:18;;5376:34;5330:2;5315:18;;5168:248;35368:162:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;35352:178;;;;:::i;:::-;;;35308:233;32098:8;35581:14;36308;;;36136:193;35581:14;35566:29;;:12;:29;:::i;:::-;:35;;;;:::i;:::-;35550:51;;;;:::i;:::-;;34365:1243;-1:-1:-1;;;;;;;34365:1243:0:o;32395:118::-;19655:21;15087:15;;;;;;;15086:16;;15133:14;;14943:30;15511:16;;:34;;;;;15531:14;15511:34;15491:54;;15555:17;15575:11;:16;;15590:1;15575:16;:50;;;;-1:-1:-1;15603:4:0;15595:25;:30;15575:50;15555:70;;15641:12;15640:13;:30;;;;;15658:12;15657:13;15640:30;15636:91;;;15693:23;;;;;;;;;;;;;;15636:91;15736:18;;;;15753:1;15736:18;;;15764:67;;;;15798:22;;;;;;;;15764:67;32469:37:::1;25480:4;32500:5:::0;32469:10:::1;:37::i;:::-;;15855:14:::0;15851:101;;;15885:23;;;;;;15927:14;;-1:-1:-1;6345:50:1;;15927:14:0;;6333:2:1;6318:18;15927:14:0;;;;;;;15851:101;14877:1081;;;;;32395:118;:::o;33416:274::-;32153:26;26308:16;26319:4;26308:10;:16::i;:::-;33608:14;:30;;;33653::::1;::::0;689:25:1;;;36584:45:0;;33653:30:::1;::::0;677:2:1;662:18;33653:30:0::1;543:177:1::0;28779:138:0;27941:7;28036:14;;;26037:28;28036:14;;;;;:24;;;26308:16;26319:4;26308:10;:16::i;:::-;28884:26:::1;28896:4;28902:7;28884:11;:26::i;33734:587::-:0;32226:27;26308:16;26319:4;26308:10;:16::i;:::-;33996:19:::1;34018:51;34034:10;34046:13;34061:7;34018:15;:51::i;:::-;33996:73;;34098:11;34083:12;:26;34079:151;;;34132:87;::::0;::::1;::::0;;::::1;::::0;::::1;5342:25:1::0;;;5383:18;;;5376:34;;;5315:18;;34132:87:0::1;5168:248:1::0;34079:151:0::1;34244:70;::::0;34302:10:::1;1707:74:1::0;;34279:13:0;;34244:70:::1;::::0;1695:2:1;1680:18;34244:70:0::1;;;;;;;33986:335;33734:587:::0;;;;;;:::o;27265:103::-;27331:30;27342:4;22081:10;27331;:30::i;:::-;27265:103;:::o;30387:387::-;30464:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;30549:219;;30592:8;:14;;;;;;;;;;;:31;;;;;;;;;;:38;;;;30626:4;30592:38;;;30676:12;22081:10;;22002:96;30676:12;30649:40;;30667:7;30649:40;;30661:4;30649:40;;;;;;;;;;30710:4;30703:11;;;;;30549:219;30752:5;30745:12;;;;;31009:388;31087:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;31172:219;;;31248:5;31214:14;;;;;;;;;;;:31;;;;;;;;;;;:39;;;;;;31272:40;22081:10;;31214:14;;31272:40;;31248:5;31272:40;31333:4;31326:11;;;;;5370:181;5444:13;5459:20;5523:4;5512:32;;;;;;;;;;;;:::i;:::-;5491:53;;;;-1:-1:-1;5370:181:0;-1:-1:-1;;5370:181:0:o;5999:603::-;-1:-1:-1;;;;;;;;;;;;;;;;;6095:13:0;6110:20;6134:28;6157:4;6134:22;:28::i;:::-;6094:68;;-1:-1:-1;6094:68:0;-1:-1:-1;4699:1:0;6176:20;;;;6172:95;;;6219:37;;;;;4638:4:1;4626:17;;6219:37:0;;;4608:36:1;4581:18;;6219:37:0;4464:186:1;6172:95:0;6574:7;6563:32;;;;;;;;;;;;:::i;:::-;6556:39;5999:603;-1:-1:-1;;;;5999:603:0:o;27498:197::-;26926:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;27581:108;;27631:47;;;;;8251:42:1;8239:55;;27631:47:0;;;8221:74:1;8311:18;;;8304:34;;;8194:18;;27631:47:0;8047:297:1;27581:108:0;27498:197;;:::o;14:332:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;180:9;167:23;230:66;223:5;219:78;212:5;209:89;199:117;;312:1;309;302:12;199:117;335:5;14:332;-1:-1:-1;;;14:332:1:o;725:180::-;784:6;837:2;825:9;816:7;812:23;808:32;805:52;;;853:1;850;843:12;805:52;-1:-1:-1;876:23:1;;725:180;-1:-1:-1;725:180:1:o;910:196::-;978:20;;1038:42;1027:54;;1017:65;;1007:93;;1096:1;1093;1086:12;1007:93;910:196;;;:::o;1111:186::-;1170:6;1223:2;1211:9;1202:7;1198:23;1194:32;1191:52;;;1239:1;1236;1229:12;1191:52;1262:29;1281:9;1262:29;:::i;1302:254::-;1370:6;1378;1431:2;1419:9;1410:7;1406:23;1402:32;1399:52;;;1447:1;1444;1437:12;1399:52;1483:9;1470:23;1460:33;;1512:38;1546:2;1535:9;1531:18;1512:38;:::i;:::-;1502:48;;1302:254;;;;;:::o;1792:184::-;1844:77;1841:1;1834:88;1941:4;1938:1;1931:15;1965:4;1962:1;1955:15;1981:334;2052:2;2046:9;2108:2;2098:13;;2113:66;2094:86;2082:99;;2211:18;2196:34;;2232:22;;;2193:62;2190:88;;;2258:18;;:::i;:::-;2294:2;2287:22;1981:334;;-1:-1:-1;1981:334:1:o;2320:245::-;2368:4;2401:18;2393:6;2390:30;2387:56;;;2423:18;;:::i;:::-;-1:-1:-1;2480:2:1;2468:15;2485:66;2464:88;2554:4;2460:99;;2320:245::o;2570:462::-;2612:5;2665:3;2658:4;2650:6;2646:17;2642:27;2632:55;;2683:1;2680;2673:12;2632:55;2719:6;2706:20;2750:48;2766:31;2794:2;2766:31;:::i;:::-;2750:48;:::i;:::-;2823:2;2814:7;2807:19;2869:3;2862:4;2857:2;2849:6;2845:15;2841:26;2838:35;2835:55;;;2886:1;2883;2876:12;2835:55;2951:2;2944:4;2936:6;2932:17;2925:4;2916:7;2912:18;2899:55;2999:1;2974:16;;;2992:4;2970:27;2963:38;;;;2978:7;2570:462;-1:-1:-1;;;2570:462:1:o;3037:456::-;3123:6;3131;3139;3192:2;3180:9;3171:7;3167:23;3163:32;3160:52;;;3208:1;3205;3198:12;3160:52;3244:9;3231:23;3221:33;;3301:2;3290:9;3286:18;3273:32;3263:42;;3356:2;3345:9;3341:18;3328:32;3383:18;3375:6;3372:30;3369:50;;;3415:1;3412;3405:12;3369:50;3438:49;3479:7;3470:6;3459:9;3455:22;3438:49;:::i;:::-;3428:59;;;3037:456;;;;;:::o;3865:594::-;3969:6;3977;3985;3993;4001;4054:3;4042:9;4033:7;4029:23;4025:33;4022:53;;;4071:1;4068;4061:12;4022:53;4107:9;4094:23;4084:33;;4164:2;4153:9;4149:18;4136:32;4126:42;;4215:2;4204:9;4200:18;4187:32;4177:42;;4266:2;4255:9;4251:18;4238:32;4228:42;;4321:3;4310:9;4306:19;4293:33;4349:18;4341:6;4338:30;4335:50;;;4381:1;4378;4371:12;4335:50;4404:49;4445:7;4436:6;4425:9;4421:22;4404:49;:::i;:::-;4394:59;;;3865:594;;;;;;;;:::o;4979:184::-;5049:6;5102:2;5090:9;5081:7;5077:23;5073:32;5070:52;;;5118:1;5115;5108:12;5070:52;-1:-1:-1;5141:16:1;;4979:184;-1:-1:-1;4979:184:1:o;5421:::-;5473:77;5470:1;5463:88;5570:4;5567:1;5560:15;5594:4;5591:1;5584:15;5610:125;5675:9;;;5696:10;;;5693:36;;;5709:18;;:::i;5740:168::-;5813:9;;;5844;;5861:15;;;5855:22;;5841:37;5831:71;;5882:18;;:::i;5913:274::-;5953:1;5979;5969:189;;6014:77;6011:1;6004:88;6115:4;6112:1;6105:15;6143:4;6140:1;6133:15;5969:189;-1:-1:-1;6172:9:1;;5913:274::o;6406:941::-;6492:6;6500;6553:2;6541:9;6532:7;6528:23;6524:32;6521:52;;;6569:1;6566;6559:12;6521:52;6601:9;6595:16;6651:4;6644:5;6640:16;6633:5;6630:27;6620:55;;6671:1;6668;6661:12;6620:55;6694:5;6684:15;;;6718:2;6764;6753:9;6749:18;6743:25;6791:18;6783:6;6780:30;6777:50;;;6823:1;6820;6813:12;6777:50;6846:22;;6899:4;6891:13;;6887:27;-1:-1:-1;6877:55:1;;6928:1;6925;6918:12;6877:55;6957:2;6951:9;6982:48;6998:31;7026:2;6998:31;:::i;6982:48::-;7053:2;7046:5;7039:17;7093:7;7088:2;7083;7079;7075:11;7071:20;7068:33;7065:53;;;7114:1;7111;7104:12;7065:53;7136:1;7146:128;7160:2;7157:1;7154:9;7146:128;;;7247:10;;;7243:19;;7237:26;7217:13;;;7213:22;;7206:58;7171:10;;7146:128;;;-1:-1:-1;7315:1:1;7294:14;;;7290:23;;;7283:34;-1:-1:-1;6406:941:1;;7298:5;;-1:-1:-1;6406:941:1;;-1:-1:-1;;6406:941:1:o;7541:501::-;7636:6;7689:2;7677:9;7668:7;7664:23;7660:32;7657:52;;;7705:1;7702;7695:12;7657:52;7738:2;7732:9;7780:2;7772:6;7768:15;7849:6;7837:10;7834:22;7813:18;7801:10;7798:34;7795:62;7792:88;;;7860:18;;:::i;:::-;7896:2;7889:22;7935:16;;7920:32;;8006:2;7991:18;;;7985:25;7968:15;;;7961:50;;;;-1:-1:-1;7927:6:1;7541:501;-1:-1:-1;7541:501:1:o","abiDefinition":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"SynapseExecutionService__FeeAmountTooLow","type":"error"},{"inputs":[],"name":"SynapseExecutionService__GasOracleNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"}],"name":"SynapseExecutionService__OptionsVersionNotSupported","type":"error"},{"inputs":[],"name":"SynapseExecutionService__ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"ExecutionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executorEOA","type":"address"}],"name":"ExecutorEOASet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gasOracle","type":"address"}],"name":"GasOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalMarkup","type":"uint256"}],"name":"GlobalMarkupSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_CLIENT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalMarkup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executorEOA_","type":"address"}],"name":"setExecutorEOA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"globalMarkup_","type":"uint256"}],"name":"setGlobalMarkup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"gasOracle()":{"notice":"Address of the gas oracle used for estimating the gas cost of the transactions."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"globalMarkup()":{"notice":"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."},"setExecutorEOA(address)":{"notice":"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains."},"setGasOracle(address)":{"notice":"Allows the contract governor to set the address of the gas oracle."},"setGlobalMarkup(uint256)":{"notice":"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates."}},"version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."},"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"gasOracle()\":{\"notice\":\"Address of the gas oracle used for estimating the gas cost of the transactions.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"globalMarkup()\":{\"notice\":\"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"},\"setExecutorEOA(address)\":{\"notice\":\"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"setGasOracle(address)\":{\"notice\":\"Allows the contract governor to set the address of the gas oracle.\"},\"setGlobalMarkup(uint256)\":{\"notice\":\"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"SynapseExecutionServiceV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","GOVERNOR_ROLE()":"ccc57490","IC_CLIENT_ROLE()":"08c5c0db","executorEOA()":"62014bad","gasOracle()":"5d62a8dd","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","getRoleAdmin(bytes32)":"248a9ca3","globalMarkup()":"efd07ec2","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","initialize(address)":"c4d66de8","renounceRole(bytes32,address)":"36568abe","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522","revokeRole(bytes32,address)":"d547741f","setExecutorEOA(address)":"2d54566c","setGasOracle(address)":"a87b8152","setGlobalMarkup(uint256)":"cf4f578f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:SynapseExecutionServiceV1Harness":{"code":"0x608060405234801561001057600080fd5b5061001c60003361004d565b506100477f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f553361004d565b5061011e565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16610112576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556100c83390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610118565b60009150505b92915050565b6114fe8061012d6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e610149366004611082565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a63660046110cb565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e836600461110d565b610476565b005b6101ed6101fd366004611128565b610587565b6101ed610210366004611128565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be366004611128565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b36600461110d565b61062f565b61018a61033e36600461126e565b61075a565b6101ed61035136600461110d565b610a03565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b3660046110cb565b610b86565b6101ed61039e366004611128565b610c26565b6101ed6103b13660046112be565b610c6a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d25565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d25565b6105cb8383610d32565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e53565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d25565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f584610f31565b509050600160ff82161115610840576040517fdaa5a14f00000000000000000000000000000000000000000000000000000000815260ff821660048201526024015b60405180910390fd5b600061084b85610f53565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091526044810188905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190611322565b6020820151909450156109a95760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b92879161095b918b91600401918252602082015260400190565b602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611322565b6109a6908561136a565b93505b670de0b6b3a76400006109da7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b6109e4908661137d565b6109ee9190611394565b6109f8908561136a565b979650505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a4e5750825b905060008267ffffffffffffffff166001148015610a6b5750303b155b905081158015610a79575080155b15610ab0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b115784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b1c600087610d32565b508315610b7e5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610bb081610d25565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c6081610d25565b6105cb8383610e53565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610c9481610d25565b6000610ca187878561075a565b905080841015610ce7576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610837565b60405133815285907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a250505050505050565b610d2f8133610fd7565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610de53390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b6000606082806020019051810190610f4991906113cf565b9094909350915050565b6040805180820190915260008082526020820152600080610f7384610f31565b9092509050600160ff83161015610fbb576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff83166004820152602401610837565b80806020019051810190610fcf9190611479565b949350505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661107e576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610837565b5050565b60006020828403121561109457600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c457600080fd5b9392505050565b6000602082840312156110dd57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461110857600080fd5b919050565b60006020828403121561111f57600080fd5b6110c4826110e4565b6000806040838503121561113b57600080fd5b8235915061114b602084016110e4565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111ca576111ca611154565b604052919050565b600067ffffffffffffffff8211156111ec576111ec611154565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261122957600080fd5b813561123c611237826111d2565b611183565b81815284602083860101111561125157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561128357600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156112a857600080fd5b6112b486828701611218565b9150509250925092565b600080600080600060a086880312156112d657600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561130957600080fd5b61131588828901611218565b9150509295509295909350565b60006020828403121561133457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104705761047061133b565b80820281158282048414176104705761047061133b565b6000826113ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600080604083850312156113e257600080fd5b825160ff811681146113f357600080fd5b8092505060208084015167ffffffffffffffff81111561141257600080fd5b8401601f8101861361142357600080fd5b8051611431611237826111d2565b818152878483850101111561144557600080fd5b60005b82811015611463578381018501518282018601528401611448565b5060009181019093015250919491935090915050565b60006040828403121561148b57600080fd5b6040516040810181811067ffffffffffffffff821117156114ae576114ae611154565b60405282518152602092830151928101929092525091905056fea26469706673582212204d9603c91ccf537ac623341f0d5212043f170827bd01b4adbdf6152bb060fd1f64736f6c63430008140033","runtime-code":"0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e610149366004611082565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a63660046110cb565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e836600461110d565b610476565b005b6101ed6101fd366004611128565b610587565b6101ed610210366004611128565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be366004611128565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b36600461110d565b61062f565b61018a61033e36600461126e565b61075a565b6101ed61035136600461110d565b610a03565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b3660046110cb565b610b86565b6101ed61039e366004611128565b610c26565b6101ed6103b13660046112be565b610c6a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d25565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d25565b6105cb8383610d32565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e53565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d25565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f584610f31565b509050600160ff82161115610840576040517fdaa5a14f00000000000000000000000000000000000000000000000000000000815260ff821660048201526024015b60405180910390fd5b600061084b85610f53565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018a905260248101919091526044810188905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa1580156108ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ee9190611322565b6020820151909450156109a95760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b92879161095b918b91600401918252602082015260400190565b602060405180830381865afa158015610978573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099c9190611322565b6109a6908561136a565b93505b670de0b6b3a76400006109da7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b6109e4908661137d565b6109ee9190611394565b6109f8908561136a565b979650505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a4e5750825b905060008267ffffffffffffffff166001148015610a6b5750303b155b905081158015610a79575080155b15610ab0576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b115784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b1c600087610d32565b508315610b7e5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610bb081610d25565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c6081610d25565b6105cb8383610e53565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610c9481610d25565b6000610ca187878561075a565b905080841015610ce7576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810185905260248101829052604401610837565b60405133815285907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a250505050505050565b610d2f8133610fd7565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610de53390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e495760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b6000606082806020019051810190610f4991906113cf565b9094909350915050565b6040805180820190915260008082526020820152600080610f7384610f31565b9092509050600160ff83161015610fbb576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff83166004820152602401610837565b80806020019051810190610fcf9190611479565b949350505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff1661107e576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610837565b5050565b60006020828403121561109457600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146110c457600080fd5b9392505050565b6000602082840312156110dd57600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461110857600080fd5b919050565b60006020828403121561111f57600080fd5b6110c4826110e4565b6000806040838503121561113b57600080fd5b8235915061114b602084016110e4565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156111ca576111ca611154565b604052919050565b600067ffffffffffffffff8211156111ec576111ec611154565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f83011261122957600080fd5b813561123c611237826111d2565b611183565b81815284602083860101111561125157600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561128357600080fd5b8335925060208401359150604084013567ffffffffffffffff8111156112a857600080fd5b6112b486828701611218565b9150509250925092565b600080600080600060a086880312156112d657600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff81111561130957600080fd5b61131588828901611218565b9150509295509295909350565b60006020828403121561133457600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156104705761047061133b565b80820281158282048414176104705761047061133b565b6000826113ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600080604083850312156113e257600080fd5b825160ff811681146113f357600080fd5b8092505060208084015167ffffffffffffffff81111561141257600080fd5b8401601f8101861361142357600080fd5b8051611431611237826111d2565b818152878483850101111561144557600080fd5b60005b82811015611463578381018501518282018601528401611448565b5060009181019093015250919491935090915050565b60006040828403121561148b57600080fd5b6040516040810181811067ffffffffffffffff821117156114ae576114ae611154565b60405282518152602092830151928101929092525091905056fea26469706673582212204d9603c91ccf537ac623341f0d5212043f170827bd01b4adbdf6152bb060fd1f64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint256 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // TODO: the \"exact version\" check should be generalized\n (uint8 version,) = OptionsLib.decodeVersionedOptions(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"36846:403:0:-:0;;;36923:180;;;;;;;;;-1:-1:-1;37007:42:0;25480:4;37038:10;37007;:42::i;:::-;-1:-1:-1;37059:37:0;32153:26;37085:10;37059;:37::i;:::-;;36846:403;;30387:387;30464:4;27018:14;;;26037:28;27018:14;;;;;;;;-1:-1:-1;;;;;27018:31:0;;;;;;;;;;;;30549:219;;30592:8;:14;;;;;;;;;;;-1:-1:-1;;;;;30592:31:0;;;;;;;;;:38;;-1:-1:-1;;30592:38:0;30626:4;30592:38;;;30676:12;22081:10;;22002:96;30676:12;-1:-1:-1;;;;;30649:40:0;30667:7;-1:-1:-1;;;;;30649:40:0;30661:4;30649:40;;;;;;;;;;30710:4;30703:11;;;;;30549:219;30752:5;30745:12;;;30387:387;;;;;:::o;36846:403::-;;;;;;;","srcMapRuntime":"36846:403:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;26560:202;;;;;;:::i;:::-;;:::i;:::-;;;516:14:1;;509:22;491:41;;479:2;464:18;26560:202:0;;;;;;;;32185:68;;32226:27;32185:68;;;;;689:25:1;;;677:2;662:18;32185:68:0;543:177:1;27876:191:0;;;;;;:::i;:::-;27941:7;28036:14;;;26037:28;28036:14;;;;;:24;;;;27876:191;32566:379;;;;;;:::i;:::-;;:::i;:::-;;28363:136;;;;;;:::i;:::-;;:::i;29465:245::-;;;;;;:::i;:::-;;:::i;35896:187::-;36065:11;;;;35896:187;;;1737:42:1;1725:55;;;1707:74;;1695:2;1680:18;35896:187:0;1561:226:1;35652:191:0;36584:45;35823:13;;;35652:191;;26849:207;;;;;;:::i;:::-;26926:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;;;;26849:207;25435:49;;25480:4;25435:49;;32998:365;;;;;;:::i;:::-;;:::i;34365:1243::-;;;;;;:::i;:::-;;:::i;32395:118::-;;;;;;:::i;:::-;;:::i;32113:66::-;;32153:26;32113:66;;33416:274;;;;;;:::i;:::-;;:::i;28779:138::-;;;;;;:::i;:::-;;:::i;33734:587::-;;;;;;:::i;:::-;;:::i;36136:193::-;36308:14;;36136:193;;26560:202;26645:4;26668:47;;;26683:32;26668:47;;:87;;-1:-1:-1;23346:25:0;23331:40;;;;26719:36;26661:94;26560:202;-1:-1:-1;;26560:202:0:o;32566:379::-;32153:26;26308:16;26319:4;26308:10;:16::i;:::-;32667:26:::1;::::0;::::1;32663:102;;32716:38;;;;;;;;;;;;;;32663:102;36584:45:::0;32867:28;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;32910::::1;::::0;1707:74:1;;;32910:28:0::1;::::0;1695:2:1;1680:18;32910:28:0::1;;;;;;;;32653:292;32566:379:::0;;:::o;28363:136::-;27941:7;28036:14;;;26037:28;28036:14;;;;;:24;;;26308:16;26319:4;26308:10;:16::i;:::-;28467:25:::1;28478:4;28484:7;28467:10;:25::i;:::-;;28363:136:::0;;;:::o;29465:245::-;29558:34;;;22081:10;29558:34;29554:102;;29615:30;;;;;;;;;;;;;;29554:102;29666:37;29678:4;29684:18;29666:11;:37::i;:::-;;29465:245;;:::o;32998:365::-;32153:26;26308:16;26319:4;26308:10;:16::i;:::-;33095:24:::1;::::0;::::1;33091:100;;33142:38;;;;;;;;;;;;;;33091:100;33293:11:::0;:24;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;33332::::1;::::0;1707:74:1;;;36584:45:0;;33332:24:::1;::::0;1695:2:1;1680:18;33332:24:0::1;1561:226:1::0;34365:1243:0;34546:20;34582:23;34608:11;36065;;;;;35896:187;34608:11;34582:37;-1:-1:-1;34633:29:0;;;34629:109;;34685:42;;;;;;;;;;;;;;34629:109;34813:13;34831:42;34865:7;34831:33;:42::i;:::-;-1:-1:-1;34812:61:0;-1:-1:-1;4699:1:0;34887:31;;;;34883:129;;;34941:60;;;;;4638:4:1;4626:17;;34941:60:0;;;4608:36:1;4581:18;;34941:60:0;;;;;;;;34883:129;35021:26;35050:35;35077:7;35050:26;:35::i;:::-;35228:18;;35110:188;;;;;;;;4857:25:1;;;4898:18;;;4891:34;;;;4941:18;;;4934:34;;;35228:18:0;;-1:-1:-1;35110:54:0;;;;;;4830:18:1;;35110:188:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;35312:20;;;;35095:203;;-1:-1:-1;35312:24:0;35308:233;;35495:20;;;;35368:162;;;;;:58;;;;;;:162;;35460:10;;35368:162;;5342:25:1;;;5398:2;5383:18;;5376:34;5330:2;5315:18;;5168:248;35368:162:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;35352:178;;;;:::i;:::-;;;35308:233;32098:8;35581:14;36308;;;36136:193;35581:14;35566:29;;:12;:29;:::i;:::-;:35;;;;:::i;:::-;35550:51;;;;:::i;:::-;;34365:1243;-1:-1:-1;;;;;;;34365:1243:0:o;32395:118::-;19655:21;15087:15;;;;;;;15086:16;;15133:14;;14943:30;15511:16;;:34;;;;;15531:14;15511:34;15491:54;;15555:17;15575:11;:16;;15590:1;15575:16;:50;;;;-1:-1:-1;15603:4:0;15595:25;:30;15575:50;15555:70;;15641:12;15640:13;:30;;;;;15658:12;15657:13;15640:30;15636:91;;;15693:23;;;;;;;;;;;;;;15636:91;15736:18;;;;15753:1;15736:18;;;15764:67;;;;15798:22;;;;;;;;15764:67;32469:37:::1;25480:4;32500:5:::0;32469:10:::1;:37::i;:::-;;15855:14:::0;15851:101;;;15885:23;;;;;;15927:14;;-1:-1:-1;6345:50:1;;15927:14:0;;6333:2:1;6318:18;15927:14:0;;;;;;;15851:101;14877:1081;;;;;32395:118;:::o;33416:274::-;32153:26;26308:16;26319:4;26308:10;:16::i;:::-;33608:14;:30;;;33653::::1;::::0;689:25:1;;;36584:45:0;;33653:30:::1;::::0;677:2:1;662:18;33653:30:0::1;543:177:1::0;28779:138:0;27941:7;28036:14;;;26037:28;28036:14;;;;;:24;;;26308:16;26319:4;26308:10;:16::i;:::-;28884:26:::1;28896:4;28902:7;28884:11;:26::i;33734:587::-:0;32226:27;26308:16;26319:4;26308:10;:16::i;:::-;33996:19:::1;34018:51;34034:10;34046:13;34061:7;34018:15;:51::i;:::-;33996:73;;34098:11;34083:12;:26;34079:151;;;34132:87;::::0;::::1;::::0;;::::1;::::0;::::1;5342:25:1::0;;;5383:18;;;5376:34;;;5315:18;;34132:87:0::1;5168:248:1::0;34079:151:0::1;34244:70;::::0;34302:10:::1;1707:74:1::0;;34279:13:0;;34244:70:::1;::::0;1695:2:1;1680:18;34244:70:0::1;;;;;;;33986:335;33734:587:::0;;;;;;:::o;27265:103::-;27331:30;27342:4;22081:10;27331;:30::i;:::-;27265:103;:::o;30387:387::-;30464:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;30549:219;;30592:8;:14;;;;;;;;;;;:31;;;;;;;;;;:38;;;;30626:4;30592:38;;;30676:12;22081:10;;22002:96;30676:12;30649:40;;30667:7;30649:40;;30661:4;30649:40;;;;;;;;;;30710:4;30703:11;;;;;30549:219;30752:5;30745:12;;;;;31009:388;31087:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;31172:219;;;31248:5;31214:14;;;;;;;;;;;:31;;;;;;;;;;;:39;;;;;;31272:40;22081:10;;31214:14;;31272:40;;31248:5;31272:40;31333:4;31326:11;;;;;5370:181;5444:13;5459:20;5523:4;5512:32;;;;;;;;;;;;:::i;:::-;5491:53;;;;-1:-1:-1;5370:181:0;-1:-1:-1;;5370:181:0:o;5999:603::-;-1:-1:-1;;;;;;;;;;;;;;;;;6095:13:0;6110:20;6134:28;6157:4;6134:22;:28::i;:::-;6094:68;;-1:-1:-1;6094:68:0;-1:-1:-1;4699:1:0;6176:20;;;;6172:95;;;6219:37;;;;;4638:4:1;4626:17;;6219:37:0;;;4608:36:1;4581:18;;6219:37:0;4464:186:1;6172:95:0;6574:7;6563:32;;;;;;;;;;;;:::i;:::-;6556:39;5999:603;-1:-1:-1;;;;5999:603:0:o;27498:197::-;26926:4;27018:14;;;26037:28;27018:14;;;;;;;;:31;;;;;;;;;;;;;27581:108;;27631:47;;;;;8251:42:1;8239:55;;27631:47:0;;;8221:74:1;8311:18;;;8304:34;;;8194:18;;27631:47:0;8047:297:1;27581:108:0;27498:197;;:::o;14:332:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;180:9;167:23;230:66;223:5;219:78;212:5;209:89;199:117;;312:1;309;302:12;199:117;335:5;14:332;-1:-1:-1;;;14:332:1:o;725:180::-;784:6;837:2;825:9;816:7;812:23;808:32;805:52;;;853:1;850;843:12;805:52;-1:-1:-1;876:23:1;;725:180;-1:-1:-1;725:180:1:o;910:196::-;978:20;;1038:42;1027:54;;1017:65;;1007:93;;1096:1;1093;1086:12;1007:93;910:196;;;:::o;1111:186::-;1170:6;1223:2;1211:9;1202:7;1198:23;1194:32;1191:52;;;1239:1;1236;1229:12;1191:52;1262:29;1281:9;1262:29;:::i;1302:254::-;1370:6;1378;1431:2;1419:9;1410:7;1406:23;1402:32;1399:52;;;1447:1;1444;1437:12;1399:52;1483:9;1470:23;1460:33;;1512:38;1546:2;1535:9;1531:18;1512:38;:::i;:::-;1502:48;;1302:254;;;;;:::o;1792:184::-;1844:77;1841:1;1834:88;1941:4;1938:1;1931:15;1965:4;1962:1;1955:15;1981:334;2052:2;2046:9;2108:2;2098:13;;2113:66;2094:86;2082:99;;2211:18;2196:34;;2232:22;;;2193:62;2190:88;;;2258:18;;:::i;:::-;2294:2;2287:22;1981:334;;-1:-1:-1;1981:334:1:o;2320:245::-;2368:4;2401:18;2393:6;2390:30;2387:56;;;2423:18;;:::i;:::-;-1:-1:-1;2480:2:1;2468:15;2485:66;2464:88;2554:4;2460:99;;2320:245::o;2570:462::-;2612:5;2665:3;2658:4;2650:6;2646:17;2642:27;2632:55;;2683:1;2680;2673:12;2632:55;2719:6;2706:20;2750:48;2766:31;2794:2;2766:31;:::i;:::-;2750:48;:::i;:::-;2823:2;2814:7;2807:19;2869:3;2862:4;2857:2;2849:6;2845:15;2841:26;2838:35;2835:55;;;2886:1;2883;2876:12;2835:55;2951:2;2944:4;2936:6;2932:17;2925:4;2916:7;2912:18;2899:55;2999:1;2974:16;;;2992:4;2970:27;2963:38;;;;2978:7;2570:462;-1:-1:-1;;;2570:462:1:o;3037:456::-;3123:6;3131;3139;3192:2;3180:9;3171:7;3167:23;3163:32;3160:52;;;3208:1;3205;3198:12;3160:52;3244:9;3231:23;3221:33;;3301:2;3290:9;3286:18;3273:32;3263:42;;3356:2;3345:9;3341:18;3328:32;3383:18;3375:6;3372:30;3369:50;;;3415:1;3412;3405:12;3369:50;3438:49;3479:7;3470:6;3459:9;3455:22;3438:49;:::i;:::-;3428:59;;;3037:456;;;;;:::o;3865:594::-;3969:6;3977;3985;3993;4001;4054:3;4042:9;4033:7;4029:23;4025:33;4022:53;;;4071:1;4068;4061:12;4022:53;4107:9;4094:23;4084:33;;4164:2;4153:9;4149:18;4136:32;4126:42;;4215:2;4204:9;4200:18;4187:32;4177:42;;4266:2;4255:9;4251:18;4238:32;4228:42;;4321:3;4310:9;4306:19;4293:33;4349:18;4341:6;4338:30;4335:50;;;4381:1;4378;4371:12;4335:50;4404:49;4445:7;4436:6;4425:9;4421:22;4404:49;:::i;:::-;4394:59;;;3865:594;;;;;;;;:::o;4979:184::-;5049:6;5102:2;5090:9;5081:7;5077:23;5073:32;5070:52;;;5118:1;5115;5108:12;5070:52;-1:-1:-1;5141:16:1;;4979:184;-1:-1:-1;4979:184:1:o;5421:::-;5473:77;5470:1;5463:88;5570:4;5567:1;5560:15;5594:4;5591:1;5584:15;5610:125;5675:9;;;5696:10;;;5693:36;;;5709:18;;:::i;5740:168::-;5813:9;;;5844;;5861:15;;;5855:22;;5841:37;5831:71;;5882:18;;:::i;5913:274::-;5953:1;5979;5969:189;;6014:77;6011:1;6004:88;6115:4;6112:1;6105:15;6143:4;6140:1;6133:15;5969:189;-1:-1:-1;6172:9:1;;5913:274::o;6406:941::-;6492:6;6500;6553:2;6541:9;6532:7;6528:23;6524:32;6521:52;;;6569:1;6566;6559:12;6521:52;6601:9;6595:16;6651:4;6644:5;6640:16;6633:5;6630:27;6620:55;;6671:1;6668;6661:12;6620:55;6694:5;6684:15;;;6718:2;6764;6753:9;6749:18;6743:25;6791:18;6783:6;6780:30;6777:50;;;6823:1;6820;6813:12;6777:50;6846:22;;6899:4;6891:13;;6887:27;-1:-1:-1;6877:55:1;;6928:1;6925;6918:12;6877:55;6957:2;6951:9;6982:48;6998:31;7026:2;6998:31;:::i;6982:48::-;7053:2;7046:5;7039:17;7093:7;7088:2;7083;7079;7075:11;7071:20;7068:33;7065:53;;;7114:1;7111;7104:12;7065:53;7136:1;7146:128;7160:2;7157:1;7154:9;7146:128;;;7247:10;;;7243:19;;7237:26;7217:13;;;7213:22;;7206:58;7171:10;;7146:128;;;-1:-1:-1;7315:1:1;7294:14;;;7290:23;;;7283:34;-1:-1:-1;6406:941:1;;7298:5;;-1:-1:-1;6406:941:1;;-1:-1:-1;;6406:941:1:o;7541:501::-;7636:6;7689:2;7677:9;7668:7;7664:23;7660:32;7657:52;;;7705:1;7702;7695:12;7657:52;7738:2;7732:9;7780:2;7772:6;7768:15;7849:6;7837:10;7834:22;7813:18;7801:10;7798:34;7795:62;7792:88;;;7860:18;;:::i;:::-;7896:2;7889:22;7935:16;;7920:32;;8006:2;7991:18;;;7985:25;7968:15;;;7961:50;;;;-1:-1:-1;7927:6:1;7541:501;-1:-1:-1;7541:501:1:o","abiDefinition":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"SynapseExecutionService__FeeAmountTooLow","type":"error"},{"inputs":[],"name":"SynapseExecutionService__GasOracleNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"version","type":"uint256"}],"name":"SynapseExecutionService__OptionsVersionNotSupported","type":"error"},{"inputs":[],"name":"SynapseExecutionService__ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"ExecutionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executorEOA","type":"address"}],"name":"ExecutorEOASet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gasOracle","type":"address"}],"name":"GasOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalMarkup","type":"uint256"}],"name":"GlobalMarkupSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_CLIENT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalMarkup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executorEOA_","type":"address"}],"name":"setExecutorEOA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"globalMarkup_","type":"uint256"}],"name":"setGlobalMarkup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"gasOracle()":{"notice":"Address of the gas oracle used for estimating the gas cost of the transactions."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"globalMarkup()":{"notice":"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."},"setExecutorEOA(address)":{"notice":"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains."},"setGasOracle(address)":{"notice":"Allows the contract governor to set the address of the gas oracle."},"setGlobalMarkup(uint256)":{"notice":"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates."}},"notice":"This harness is supposed to be used IN TESTS ONLY.","version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."},"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"version\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"gasOracle()\":{\"notice\":\"Address of the gas oracle used for estimating the gas cost of the transactions.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"globalMarkup()\":{\"notice\":\"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"},\"setExecutorEOA(address)\":{\"notice\":\"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"setGasOracle(address)\":{\"notice\":\"Allows the contract governor to set the address of the gas oracle.\"},\"setGlobalMarkup(uint256)\":{\"notice\":\"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\"}},\"notice\":\"This harness is supposed to be used IN TESTS ONLY.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"SynapseExecutionServiceV1Harness\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xc913356ea01a18692d2148bebf413d5f3d0e663c6a728425fd72a67557ca71e5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18cee47688ca3246f6a86e4d2c489d82ffcbde9aafe1233d4d5f7426e48678ca\",\"dweb:/ipfs/QmcLpFhAcNuk8WBJukkmETaHeVdZ7j3uEDrDUgyAESTbt8\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","GOVERNOR_ROLE()":"ccc57490","IC_CLIENT_ROLE()":"08c5c0db","executorEOA()":"62014bad","gasOracle()":"5d62a8dd","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","getRoleAdmin(bytes32)":"248a9ca3","globalMarkup()":"efd07ec2","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","initialize(address)":"c4d66de8","renounceRole(bytes32,address)":"36568abe","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522","revokeRole(bytes32,address)":"d547741f","setExecutorEOA(address)":"2d54566c","setGasOracle(address)":"a87b8152","setGlobalMarkup(uint256)":"cf4f578f","supportsInterface(bytes4)":"01ffc9a7"}}} \ No newline at end of file +{"solidity/SynapseExecutionServiceV1Harness.sol:AccessControlUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."},"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"AccessControlUpgradeable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:ContextUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","errors":{"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"}],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"errors\":{\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"ContextUpgradeable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:ERC165Upgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```","errors":{"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```\",\"errors\":{\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"ERC165Upgradeable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:IAccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"External interface of AccessControl declared to support ERC165 detection.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"External interface of AccessControl declared to support ERC165 detection.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IAccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"solidity/SynapseExecutionServiceV1Harness.sol:IERC165":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.","kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.\",\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IERC165\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:IExecutionService":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IExecutionService\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"executorEOA()":"62014bad","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522"}},"solidity/SynapseExecutionServiceV1Harness.sol:IGasOracle":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"remoteChainId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"convertRemoteValueToLocalUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"remoteChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"calldataSize","type":"uint256"}],"name":"estimateTxCostInLocalUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"remoteChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"calldataSize","type":"uint256"}],"name":"estimateTxCostInRemoteUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"convertRemoteValueToLocalUnits(uint256,uint256)":{"notice":"Convert a value from the native token of a remote chain to the local native token."},"estimateTxCostInLocalUnits(uint256,uint256,uint256)":{"notice":"Estimate the cost of execution a transaction on a remote chain, and convert it to the local native token."},"estimateTxCostInRemoteUnits(uint256,uint256,uint256)":{"notice":"Estimate the cost of execution a transaction on a remote chain, and return it as is in the remote chain's native token."}},"version":1},"developerDoc":{"kind":"dev","methods":{"convertRemoteValueToLocalUnits(uint256,uint256)":{"details":"Will revert if no price is available for the remote chain.","params":{"remoteChainId":"The chain id of the remote chain.","value":"The value to convert."}},"estimateTxCostInLocalUnits(uint256,uint256,uint256)":{"details":"Will revert if no price is available for the remote chain.","params":{"calldataSize":"The size of the transaction calldata.","gasLimit":"The gas limit of the transaction.","remoteChainId":"The chain id of the remote chain."}},"estimateTxCostInRemoteUnits(uint256,uint256,uint256)":{"details":"Will revert if no price is available for the remote chain.","params":{"calldataSize":"The size of the transaction calldata.","gasLimit":"The gas limit of the transaction.","remoteChainId":"The chain id of the remote chain."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"remoteChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"convertRemoteValueToLocalUnits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"remoteChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"calldataSize\",\"type\":\"uint256\"}],\"name\":\"estimateTxCostInLocalUnits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"remoteChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"calldataSize\",\"type\":\"uint256\"}],\"name\":\"estimateTxCostInRemoteUnits\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"convertRemoteValueToLocalUnits(uint256,uint256)\":{\"details\":\"Will revert if no price is available for the remote chain.\",\"params\":{\"remoteChainId\":\"The chain id of the remote chain.\",\"value\":\"The value to convert.\"}},\"estimateTxCostInLocalUnits(uint256,uint256,uint256)\":{\"details\":\"Will revert if no price is available for the remote chain.\",\"params\":{\"calldataSize\":\"The size of the transaction calldata.\",\"gasLimit\":\"The gas limit of the transaction.\",\"remoteChainId\":\"The chain id of the remote chain.\"}},\"estimateTxCostInRemoteUnits(uint256,uint256,uint256)\":{\"details\":\"Will revert if no price is available for the remote chain.\",\"params\":{\"calldataSize\":\"The size of the transaction calldata.\",\"gasLimit\":\"The gas limit of the transaction.\",\"remoteChainId\":\"The chain id of the remote chain.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"convertRemoteValueToLocalUnits(uint256,uint256)\":{\"notice\":\"Convert a value from the native token of a remote chain to the local native token.\"},\"estimateTxCostInLocalUnits(uint256,uint256,uint256)\":{\"notice\":\"Estimate the cost of execution a transaction on a remote chain, and convert it to the local native token.\"},\"estimateTxCostInRemoteUnits(uint256,uint256,uint256)\":{\"notice\":\"Estimate the cost of execution a transaction on a remote chain, and return it as is in the remote chain's native token.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"IGasOracle\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"convertRemoteValueToLocalUnits(uint256,uint256)":"1e7b9287","estimateTxCostInLocalUnits(uint256,uint256,uint256)":"5cbd3c48","estimateTxCostInRemoteUnits(uint256,uint256,uint256)":"fd6a7167"}},"solidity/SynapseExecutionServiceV1Harness.sol:ISynapseExecutionServiceV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"SynapseExecutionService__FeeAmountTooLow","type":"error"},{"inputs":[],"name":"SynapseExecutionService__GasOracleNotSet","type":"error"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"SynapseExecutionService__OptionsVersionNotSupported","type":"error"},{"inputs":[],"name":"SynapseExecutionService__ZeroAddress","type":"error"},{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalMarkup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executorEOA_","type":"address"}],"name":"setExecutorEOA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"globalMarkup_","type":"uint256"}],"name":"setGlobalMarkup","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"gasOracle()":{"notice":"Address of the gas oracle used for estimating the gas cost of the transactions."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"globalMarkup()":{"notice":"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."},"setExecutorEOA(address)":{"notice":"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains."},"setGasOracle(address)":{"notice":"Allows the contract governor to set the address of the gas oracle."},"setGlobalMarkup(uint256)":{"notice":"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"gasOracle()\":{\"notice\":\"Address of the gas oracle used for estimating the gas cost of the transactions.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"globalMarkup()\":{\"notice\":\"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"},\"setExecutorEOA(address)\":{\"notice\":\"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"setGasOracle(address)\":{\"notice\":\"Allows the contract governor to set the address of the gas oracle.\"},\"setGlobalMarkup(uint256)\":{\"notice\":\"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"ISynapseExecutionServiceV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"executorEOA()":"62014bad","gasOracle()":"5d62a8dd","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","globalMarkup()":"efd07ec2","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522","setExecutorEOA(address)":"2d54566c","setGasOracle(address)":"a87b8152","setGlobalMarkup(uint256)":"cf4f578f"}},"solidity/SynapseExecutionServiceV1Harness.sol:Initializable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"custom:oz-upgrades-unsafe-allow":"constructor constructor() { _disableInitializers(); } ``` ====","details":"This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in case an upgrade adds a module that needs to be initialized. For example: [.hljs-theme-light.nopadding] ```solidity contract MyToken is ERC20Upgradeable { function initialize() initializer public { __ERC20_init(\"MyToken\", \"MTK\"); } } contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { function initializeV2() reinitializer(2) public { __ERC20Permit_init(\"MyToken\"); } } ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding] ```","errors":{"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"}],\"devdoc\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor constructor() { _disableInitializers(); } ``` ====\",\"details\":\"This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in case an upgrade adds a module that needs to be initialized. For example: [.hljs-theme-light.nopadding] ```solidity contract MyToken is ERC20Upgradeable { function initialize() initializer public { __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\"); } } contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { function initializeV2() reinitializer(2) public { __ERC20Permit_init(\\\"MyToken\\\"); } } ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding] ```\",\"errors\":{\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"Initializable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ef4765fee3cfa820e1c89acd7a4e2156cd279f18c23acafb5d7db42b5dd338fb64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ef4765fee3cfa820e1c89acd7a4e2156cd279f18c23acafb5d7db42b5dd338fb64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"23059:1233:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;23059:1233:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"23059:1233:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:SynapseExecutionServiceEvents":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"ExecutionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executorEOA","type":"address"}],"name":"ExecutorEOASet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gasOracle","type":"address"}],"name":"GasOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalMarkup","type":"uint256"}],"name":"GlobalMarkupSet","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"SynapseExecutionServiceEvents\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{}},"solidity/SynapseExecutionServiceV1Harness.sol:SynapseExecutionServiceV1":{"code":"0x608060405234801561001057600080fd5b5061001961001e565b6100d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff161561006e5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100cd5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b611641806100df6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e61014936600461122f565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a6366004611271565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e83660046112b3565b610476565b005b6101ed6101fd3660046112ce565b610587565b6101ed6102103660046112ce565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be3660046112ce565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b3660046112b3565b61062f565b61018a61033e366004611343565b61075a565b6101ed6103513660046112b3565b610a3c565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b366004611271565b610bbf565b6101ed61039e3660046112ce565b610c5f565b6101ed6103b1366004611396565b610ca3565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d60565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d60565b6105cb8383610d6d565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e8e565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d60565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f68585610f6c565b9050600161ffff82161115610842576040517f05e98f3a00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b600061088386868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610fb692505050565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018b905260248101919091526044810189905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190611400565b6020820151909450156109e15760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b928791610993918c91600401918252602082015260400190565b602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611400565b6109de9085611448565b93505b670de0b6b3a7640000610a127fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b610a1c908661145b565b610a269190611472565b610a309085611448565b98975050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a875750825b905060008267ffffffffffffffff166001148015610aa45750303b155b905081158015610ab2575080155b15610ae9576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b4a5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b55600087610d6d565b508315610bb75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610be981610d60565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c9981610d60565b6105cb8383610e8e565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610ccd81610d60565b6000610cdb8888868661075a565b905080851015610d21576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610839565b60405133815286907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a25050505050505050565b610d6a813361103f565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610e203390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b60006002821015610fad5782826040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016108399291906114ad565b50503560f01c90565b60408051808201909152600080825260208201526000610fd5836110ea565b9050600161ffff8216101561101c576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff82166004820152602401610839565b61102583611135565b8060200190518101906110389190611529565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110e6576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610839565b5050565b600060028251101561112a57816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b506020015160f01c90565b606060028251101561117557816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156111b2576111b26114fa565b6040519080825280601f01601f1916602001820160405280156111dc576020820181803683370190505b50915060008160208401836022870160045afa905080611228576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561124157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461103857600080fd5b60006020828403121561128357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112ae57600080fd5b919050565b6000602082840312156112c557600080fd5b6110388261128a565b600080604083850312156112e157600080fd5b823591506112f16020840161128a565b90509250929050565b60008083601f84011261130c57600080fd5b50813567ffffffffffffffff81111561132457600080fd5b60208301915083602082850101111561133c57600080fd5b9250929050565b6000806000806060858703121561135957600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561137e57600080fd5b61138a878288016112fa565b95989497509550505050565b60008060008060008060a087890312156113af57600080fd5b86359550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156113e257600080fd5b6113ee89828a016112fa565b979a9699509497509295939492505050565b60006020828403121561141257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047057610470611419565b808202811582820484141761047057610470611419565b6000826114a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006040828403121561153b57600080fd5b6040516040810181811067ffffffffffffffff82111715611585577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b600060208083528351808285015260005b818110156115cc578581018301518582016040015282016115b0565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509291505056fea264697066735822122073ac682035a1c9af569f83acef83df3f74f4bfc62dfd61335eaf24679880326e64736f6c63430008140033","runtime-code":"0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e61014936600461122f565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a6366004611271565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e83660046112b3565b610476565b005b6101ed6101fd3660046112ce565b610587565b6101ed6102103660046112ce565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be3660046112ce565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b3660046112b3565b61062f565b61018a61033e366004611343565b61075a565b6101ed6103513660046112b3565b610a3c565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b366004611271565b610bbf565b6101ed61039e3660046112ce565b610c5f565b6101ed6103b1366004611396565b610ca3565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d60565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d60565b6105cb8383610d6d565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e8e565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d60565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f68585610f6c565b9050600161ffff82161115610842576040517f05e98f3a00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b600061088386868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610fb692505050565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018b905260248101919091526044810189905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190611400565b6020820151909450156109e15760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b928791610993918c91600401918252602082015260400190565b602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611400565b6109de9085611448565b93505b670de0b6b3a7640000610a127fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b610a1c908661145b565b610a269190611472565b610a309085611448565b98975050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a875750825b905060008267ffffffffffffffff166001148015610aa45750303b155b905081158015610ab2575080155b15610ae9576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b4a5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b55600087610d6d565b508315610bb75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610be981610d60565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c9981610d60565b6105cb8383610e8e565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610ccd81610d60565b6000610cdb8888868661075a565b905080851015610d21576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610839565b60405133815286907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a25050505050505050565b610d6a813361103f565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610e203390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b60006002821015610fad5782826040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016108399291906114ad565b50503560f01c90565b60408051808201909152600080825260208201526000610fd5836110ea565b9050600161ffff8216101561101c576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff82166004820152602401610839565b61102583611135565b8060200190518101906110389190611529565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110e6576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610839565b5050565b600060028251101561112a57816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b506020015160f01c90565b606060028251101561117557816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156111b2576111b26114fa565b6040519080825280601f01601f1916602001820160405280156111dc576020820181803683370190505b50915060008160208401836022870160045afa905080611228576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561124157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461103857600080fd5b60006020828403121561128357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112ae57600080fd5b919050565b6000602082840312156112c557600080fd5b6110388261128a565b600080604083850312156112e157600080fd5b823591506112f16020840161128a565b90509250929050565b60008083601f84011261130c57600080fd5b50813567ffffffffffffffff81111561132457600080fd5b60208301915083602082850101111561133c57600080fd5b9250929050565b6000806000806060858703121561135957600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561137e57600080fd5b61138a878288016112fa565b95989497509550505050565b60008060008060008060a087890312156113af57600080fd5b86359550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156113e257600080fd5b6113ee89828a016112fa565b979a9699509497509295939492505050565b60006020828403121561141257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047057610470611419565b808202811582820484141761047057610470611419565b6000826114a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006040828403121561153b57600080fd5b6040516040810181811067ffffffffffffffff82111715611585577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b600060208083528351808285015260005b818110156115cc578581018301518582016040015282016115b0565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509291505056fea264697066735822122073ac682035a1c9af569f83acef83df3f74f4bfc62dfd61335eaf24679880326e64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"34594:5276:0:-:0;;;35399:129;;;;;;;;;-1:-1:-1;35499:22:0;:20;:22::i;:::-;34594:5276;;19884:422;21043:21;20073:15;;;;;;;20069:76;;;20111:23;;-1:-1:-1;;;20111:23:0;;;;;;;;;;;20069:76;20158:14;;-1:-1:-1;;;;;20158:14:0;;;:34;20154:146;;20208:33;;-1:-1:-1;;;;;;20208:33:0;-1:-1:-1;;;;;20208:33:0;;;;;20260:29;;158:50:1;;;20260:29:0;;146:2:1;131:18;20260:29:0;;;;;;;20154:146;19933:373;19884:422::o;14:200:1:-;34594:5276:0;;;;;;","srcMapRuntime":"34594:5276:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;29699:202;;;;;;:::i;:::-;;:::i;:::-;;;516:14:1;;509:22;491:41;;479:2;464:18;29699:202:0;;;;;;;;35324:68;;35365:27;35324:68;;;;;689:25:1;;;677:2;662:18;35324:68:0;543:177:1;31015:191:0;;;;;;:::i;:::-;31080:7;31175:14;;;29176:28;31175:14;;;;;:24;;;;31015:191;35705:379;;;;;;:::i;:::-;;:::i;:::-;;31502:136;;;;;;:::i;:::-;;:::i;32604:245::-;;;;;;:::i;:::-;;:::i;39119:187::-;39288:11;;;;39119:187;;;1737:42:1;1725:55;;;1707:74;;1695:2;1680:18;39119:187:0;1561:226:1;38875:191:0;39807:45;39046:13;;;38875:191;;29988:207;;;;;;:::i;:::-;30065:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;;;;29988:207;28574:49;;28619:4;28574:49;;36137:365;;;;;;:::i;:::-;;:::i;37506:1325::-;;;;;;:::i;:::-;;:::i;35534:118::-;;;;;;:::i;:::-;;:::i;35252:66::-;;35292:26;35252:66;;36555:274;;;;;;:::i;:::-;;:::i;31918:138::-;;;;;;:::i;:::-;;:::i;36873:589::-;;;;;;:::i;:::-;;:::i;39359:193::-;39531:14;;39359:193;;29699:202;29784:4;29807:47;;;29822:32;29807:47;;:87;;-1:-1:-1;26485:25:0;26470:40;;;;29858:36;29800:94;29699:202;-1:-1:-1;;29699:202:0:o;35705:379::-;35292:26;29447:16;29458:4;29447:10;:16::i;:::-;35806:26:::1;::::0;::::1;35802:102;;35855:38;;;;;;;;;;;;;;35802:102;39807:45:::0;36006:28;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;36049::::1;::::0;1707:74:1;;;36049:28:0::1;::::0;1695:2:1;1680:18;36049:28:0::1;;;;;;;;35792:292;35705:379:::0;;:::o;31502:136::-;31080:7;31175:14;;;29176:28;31175:14;;;;;:24;;;29447:16;29458:4;29447:10;:16::i;:::-;31606:25:::1;31617:4;31623:7;31606:10;:25::i;:::-;;31502:136:::0;;;:::o;32604:245::-;32697:34;;;25220:10;32697:34;32693:102;;32754:30;;;;;;;;;;;;;;32693:102;32805:37;32817:4;32823:18;32805:11;:37::i;:::-;;32604:245;;:::o;36137:365::-;35292:26;29447:16;29458:4;29447:10;:16::i;:::-;36234:24:::1;::::0;::::1;36230:100;;36281:38;;;;;;;;;;;;;;36230:100;36432:11:::0;:24;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;36471::::1;::::0;1707:74:1;;;39807:45:0;;36471:24:::1;::::0;1695:2:1;1680:18;36471:24:0::1;1561:226:1::0;37506:1325:0;37689:20;37725:23;37751:11;39288;;;;;39119:187;37751:11;37725:37;-1:-1:-1;37776:29:0;;;37772:109;;37828:42;;;;;;;;;;;;;;37772:109;38040:14;38057:39;38088:7;;38057:30;:39::i;:::-;38040:56;-1:-1:-1;23164:1:0;38110:31;;;;38106:129;;;38164:60;;;;;3923:6:1;3911:19;;38164:60:0;;;3893:38:1;3866:18;;38164:60:0;;;;;;;;38106:129;38244:26;38273:35;38300:7;;38273:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;38273:26:0;;-1:-1:-1;;;38273:35:0:i;:::-;38451:18;;38333:188;;;;;;;;4144:25:1;;;4185:18;;;4178:34;;;;4228:18;;;4221:34;;;38451:18:0;;-1:-1:-1;38333:54:0;;;;;;4117:18:1;;38333:188:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;38535:20;;;;38318:203;;-1:-1:-1;38535:24:0;38531:233;;38718:20;;;;38591:162;;;;;:58;;;;;;:162;;38683:10;;38591:162;;4629:25:1;;;4685:2;4670:18;;4663:34;4617:2;4602:18;;4455:248;38591:162:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;38575:178;;;;:::i;:::-;;;38531:233;35237:8;38804:14;39531;;;39359:193;38804:14;38789:29;;:12;:29;:::i;:::-;:35;;;;:::i;:::-;38773:51;;;;:::i;:::-;;37506:1325;-1:-1:-1;;;;;;;;37506:1325:0:o;35534:118::-;21043:21;16475:15;;;;;;;16474:16;;16521:14;;16331:30;16899:16;;:34;;;;;16919:14;16899:34;16879:54;;16943:17;16963:11;:16;;16978:1;16963:16;:50;;;;-1:-1:-1;16991:4:0;16983:25;:30;16963:50;16943:70;;17029:12;17028:13;:30;;;;;17046:12;17045:13;17028:30;17024:91;;;17081:23;;;;;;;;;;;;;;17024:91;17124:18;;;;17141:1;17124:18;;;17152:67;;;;17186:22;;;;;;;;17152:67;35608:37:::1;28619:4;35639:5:::0;35608:10:::1;:37::i;:::-;;17243:14:::0;17239:101;;;17273:23;;;;;;17315:14;;-1:-1:-1;5632:50:1;;17315:14:0;;5620:2:1;5605:18;17315:14:0;;;;;;;17239:101;16265:1081;;;;;35534:118;:::o;36555:274::-;35292:26;29447:16;29458:4;29447:10;:16::i;:::-;36747:14;:30;;;36792::::1;::::0;689:25:1;;;39807:45:0;;36792:30:::1;::::0;677:2:1;662:18;36792:30:0::1;543:177:1::0;31918:138:0;31080:7;31175:14;;;29176:28;31175:14;;;;;:24;;;29447:16;29458:4;29447:10;:16::i;:::-;32023:26:::1;32035:4;32041:7;32023:11;:26::i;36873:589::-:0;35365:27;29447:16;29458:4;29447:10;:16::i;:::-;37137:19:::1;37159:51;37175:10;37187:13;37202:7;;37159:15;:51::i;:::-;37137:73;;37239:11;37224:12;:26;37220:151;;;37273:87;::::0;::::1;::::0;;::::1;::::0;::::1;4629:25:1::0;;;4670:18;;;4663:34;;;4602:18;;37273:87:0::1;4455:248:1::0;37220:151:0::1;37385:70;::::0;37443:10:::1;1707:74:1::0;;37420:13:0;;37385:70:::1;::::0;1695:2:1;1680:18;37385:70:0::1;;;;;;;37127:335;36873:589:::0;;;;;;;:::o;30404:103::-;30470:30;30481:4;25220:10;30470;:30::i;:::-;30404:103;:::o;33526:387::-;33603:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;33688:219;;33731:8;:14;;;;;;;;;;;:31;;;;;;;;;;:38;;;;33765:4;33731:38;;;33815:12;25220:10;;25141:96;33815:12;33788:40;;33806:7;33788:40;;33800:4;33788:40;;;;;;;;;;33849:4;33842:11;;;;;33688:219;33891:5;33884:12;;;;;34148:388;34226:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;34311:219;;;34387:5;34353:14;;;;;;;;;;;:31;;;;;;;;;;;:39;;;;;;34411:40;25220:10;;34353:14;;34411:40;;34387:5;34411:40;34472:4;34465:11;;;;;5026:425;5102:14;4403:1;5132:40;;5128:122;;;5222:16;;5195:44;;;;;;;;;;;;:::i;5128:122::-;-1:-1:-1;;5397:37:0;5392:3;5388:47;;5026:425::o;23389:599::-;-1:-1:-1;;;;;;;;;;;;;;;;;23484:14:0;23501:27;:4;:25;:27::i;:::-;23484:44;-1:-1:-1;23164:1:0;23542:20;;;;23538:95;;;23585:37;;;;;3923:6:1;3911:19;;23585:37:0;;;3893:38:1;3866:18;;23585:37:0;3749:188:1;23538:95:0;23940:27;:4;:25;:27::i;:::-;23929:52;;;;;;;;;;;;:::i;:::-;23922:59;23389:599;-1:-1:-1;;;23389:599:0:o;30637:197::-;30065:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;30720:108;;30770:47;;;;;7199:42:1;7187:55;;30770:47:0;;;7169:74:1;7259:18;;;7252:34;;;7142:18;;30770:47:0;6995:297:1;30720:108:0;30637:197;;:::o;6127:496::-;6211:14;4403:1;6241:16;:23;:40;6237:122;;;6331:16;6304:44;;;;;;;;;;;:::i;6237:122::-;-1:-1:-1;6600:4:0;6578:27;6572:34;6567:3;6563:44;;6127:496::o;6937:1053::-;7021:20;4403:1;7057:16;:23;:40;7053:122;;;7147:16;7120:44;;;;;;;;;;;:::i;7053:122::-;7333:23;;:40;;;7403:17;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7403:17:0;;7393:27;;7544:8;7880:6;7873:4;7864:7;7860:18;7852:6;7845:4;7827:16;7823:27;7817:4;7810:5;7799:88;7792:95;;7911:3;7906:78;;7937:36;;;;;;;;;;;;;;7906:78;7043:947;;6937:1053;;;:::o;14:332:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;180:9;167:23;230:66;223:5;219:78;212:5;209:89;199:117;;312:1;309;302:12;725:180;784:6;837:2;825:9;816:7;812:23;808:32;805:52;;;853:1;850;843:12;805:52;-1:-1:-1;876:23:1;;725:180;-1:-1:-1;725:180:1:o;910:196::-;978:20;;1038:42;1027:54;;1017:65;;1007:93;;1096:1;1093;1086:12;1007:93;910:196;;;:::o;1111:186::-;1170:6;1223:2;1211:9;1202:7;1198:23;1194:32;1191:52;;;1239:1;1236;1229:12;1191:52;1262:29;1281:9;1262:29;:::i;1302:254::-;1370:6;1378;1431:2;1419:9;1410:7;1406:23;1402:32;1399:52;;;1447:1;1444;1437:12;1399:52;1483:9;1470:23;1460:33;;1512:38;1546:2;1535:9;1531:18;1512:38;:::i;:::-;1502:48;;1302:254;;;;;:::o;1792:347::-;1843:8;1853:6;1907:3;1900:4;1892:6;1888:17;1884:27;1874:55;;1925:1;1922;1915:12;1874:55;-1:-1:-1;1948:20:1;;1991:18;1980:30;;1977:50;;;2023:1;2020;2013:12;1977:50;2060:4;2052:6;2048:17;2036:29;;2112:3;2105:4;2096:6;2088;2084:19;2080:30;2077:39;2074:59;;;2129:1;2126;2119:12;2074:59;1792:347;;;;;:::o;2144:545::-;2232:6;2240;2248;2256;2309:2;2297:9;2288:7;2284:23;2280:32;2277:52;;;2325:1;2322;2315:12;2277:52;2361:9;2348:23;2338:33;;2418:2;2407:9;2403:18;2390:32;2380:42;;2473:2;2462:9;2458:18;2445:32;2500:18;2492:6;2489:30;2486:50;;;2532:1;2529;2522:12;2486:50;2571:58;2621:7;2612:6;2601:9;2597:22;2571:58;:::i;:::-;2144:545;;;;-1:-1:-1;2648:8:1;-1:-1:-1;;;;2144:545:1:o;3061:683::-;3167:6;3175;3183;3191;3199;3207;3260:3;3248:9;3239:7;3235:23;3231:33;3228:53;;;3277:1;3274;3267:12;3228:53;3313:9;3300:23;3290:33;;3370:2;3359:9;3355:18;3342:32;3332:42;;3421:2;3410:9;3406:18;3393:32;3383:42;;3472:2;3461:9;3457:18;3444:32;3434:42;;3527:3;3516:9;3512:19;3499:33;3555:18;3547:6;3544:30;3541:50;;;3587:1;3584;3577:12;3541:50;3626:58;3676:7;3667:6;3656:9;3652:22;3626:58;:::i;:::-;3061:683;;;;-1:-1:-1;3061:683:1;;-1:-1:-1;3061:683:1;;3703:8;;3061:683;-1:-1:-1;;;3061:683:1:o;4266:184::-;4336:6;4389:2;4377:9;4368:7;4364:23;4360:32;4357:52;;;4405:1;4402;4395:12;4357:52;-1:-1:-1;4428:16:1;;4266:184;-1:-1:-1;4266:184:1:o;4708:::-;4760:77;4757:1;4750:88;4857:4;4854:1;4847:15;4881:4;4878:1;4871:15;4897:125;4962:9;;;4983:10;;;4980:36;;;4996:18;;:::i;5027:168::-;5100:9;;;5131;;5148:15;;;5142:22;;5128:37;5118:71;;5169:18;;:::i;5200:274::-;5240:1;5266;5256:189;;5301:77;5298:1;5291:88;5402:4;5399:1;5392:15;5430:4;5427:1;5420:15;5256:189;-1:-1:-1;5459:9:1;;5200:274::o;5693:447::-;5850:2;5839:9;5832:21;5889:6;5884:2;5873:9;5869:18;5862:34;5946:6;5938;5933:2;5922:9;5918:18;5905:48;6002:1;5973:22;;;5997:2;5969:31;;;5962:42;;;;6056:2;6044:15;;;6061:66;6040:88;6025:104;6021:113;;5693:447;-1:-1:-1;5693:447:1:o;6145:184::-;6197:77;6194:1;6187:88;6294:4;6291:1;6284:15;6318:4;6315:1;6308:15;6334:656;6430:6;6483:2;6471:9;6462:7;6458:23;6454:32;6451:52;;;6499:1;6496;6489:12;6451:52;6532:2;6526:9;6574:2;6566:6;6562:15;6643:6;6631:10;6628:22;6607:18;6595:10;6592:34;6589:62;6586:242;;;6684:77;6681:1;6674:88;6785:4;6782:1;6775:15;6813:4;6810:1;6803:15;6586:242;6844:2;6837:22;6883:16;;6868:32;;6954:2;6939:18;;;6933:25;6916:15;;;6909:50;;;;-1:-1:-1;6875:6:1;6334:656;-1:-1:-1;6334:656:1:o;7297:605::-;7407:4;7436:2;7465;7454:9;7447:21;7497:6;7491:13;7540:6;7535:2;7524:9;7520:18;7513:34;7565:1;7575:140;7589:6;7586:1;7583:13;7575:140;;;7684:14;;;7680:23;;7674:30;7650:17;;;7669:2;7646:26;7639:66;7604:10;;7575:140;;;7579:3;7764:1;7759:2;7750:6;7739:9;7735:22;7731:31;7724:42;7893:2;7823:66;7818:2;7810:6;7806:15;7802:88;7791:9;7787:104;7783:113;7775:121;;;;7297:605;;;;:::o","abiDefinition":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"SynapseExecutionService__FeeAmountTooLow","type":"error"},{"inputs":[],"name":"SynapseExecutionService__GasOracleNotSet","type":"error"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"SynapseExecutionService__OptionsVersionNotSupported","type":"error"},{"inputs":[],"name":"SynapseExecutionService__ZeroAddress","type":"error"},{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"ExecutionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executorEOA","type":"address"}],"name":"ExecutorEOASet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gasOracle","type":"address"}],"name":"GasOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalMarkup","type":"uint256"}],"name":"GlobalMarkupSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_CLIENT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalMarkup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executorEOA_","type":"address"}],"name":"setExecutorEOA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"globalMarkup_","type":"uint256"}],"name":"setGlobalMarkup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"gasOracle()":{"notice":"Address of the gas oracle used for estimating the gas cost of the transactions."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"globalMarkup()":{"notice":"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."},"setExecutorEOA(address)":{"notice":"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains."},"setGasOracle(address)":{"notice":"Allows the contract governor to set the address of the gas oracle."},"setGlobalMarkup(uint256)":{"notice":"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates."}},"version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."},"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"gasOracle()\":{\"notice\":\"Address of the gas oracle used for estimating the gas cost of the transactions.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"globalMarkup()\":{\"notice\":\"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"},\"setExecutorEOA(address)\":{\"notice\":\"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"setGasOracle(address)\":{\"notice\":\"Allows the contract governor to set the address of the gas oracle.\"},\"setGlobalMarkup(uint256)\":{\"notice\":\"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"SynapseExecutionServiceV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","GOVERNOR_ROLE()":"ccc57490","IC_CLIENT_ROLE()":"08c5c0db","executorEOA()":"62014bad","gasOracle()":"5d62a8dd","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","getRoleAdmin(bytes32)":"248a9ca3","globalMarkup()":"efd07ec2","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","initialize(address)":"c4d66de8","renounceRole(bytes32,address)":"36568abe","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522","revokeRole(bytes32,address)":"d547741f","setExecutorEOA(address)":"2d54566c","setGasOracle(address)":"a87b8152","setGlobalMarkup(uint256)":"cf4f578f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:SynapseExecutionServiceV1Harness":{"code":"0x608060405234801561001057600080fd5b5061001c60003361004d565b506100477f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f553361004d565b5061011e565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602081815260408084206001600160a01b038616855290915282205460ff16610112576000848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556100c83390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610118565b60009150505b92915050565b6116418061012d6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e61014936600461122f565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a6366004611271565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e83660046112b3565b610476565b005b6101ed6101fd3660046112ce565b610587565b6101ed6102103660046112ce565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be3660046112ce565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b3660046112b3565b61062f565b61018a61033e366004611343565b61075a565b6101ed6103513660046112b3565b610a3c565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b366004611271565b610bbf565b6101ed61039e3660046112ce565b610c5f565b6101ed6103b1366004611396565b610ca3565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d60565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d60565b6105cb8383610d6d565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e8e565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d60565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f68585610f6c565b9050600161ffff82161115610842576040517f05e98f3a00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b600061088386868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610fb692505050565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018b905260248101919091526044810189905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190611400565b6020820151909450156109e15760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b928791610993918c91600401918252602082015260400190565b602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611400565b6109de9085611448565b93505b670de0b6b3a7640000610a127fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b610a1c908661145b565b610a269190611472565b610a309085611448565b98975050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a875750825b905060008267ffffffffffffffff166001148015610aa45750303b155b905081158015610ab2575080155b15610ae9576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b4a5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b55600087610d6d565b508315610bb75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610be981610d60565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c9981610d60565b6105cb8383610e8e565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610ccd81610d60565b6000610cdb8888868661075a565b905080851015610d21576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610839565b60405133815286907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a25050505050505050565b610d6a813361103f565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610e203390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b60006002821015610fad5782826040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016108399291906114ad565b50503560f01c90565b60408051808201909152600080825260208201526000610fd5836110ea565b9050600161ffff8216101561101c576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff82166004820152602401610839565b61102583611135565b8060200190518101906110389190611529565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110e6576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610839565b5050565b600060028251101561112a57816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b506020015160f01c90565b606060028251101561117557816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156111b2576111b26114fa565b6040519080825280601f01601f1916602001820160405280156111dc576020820181803683370190505b50915060008160208401836022870160045afa905080611228576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561124157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461103857600080fd5b60006020828403121561128357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112ae57600080fd5b919050565b6000602082840312156112c557600080fd5b6110388261128a565b600080604083850312156112e157600080fd5b823591506112f16020840161128a565b90509250929050565b60008083601f84011261130c57600080fd5b50813567ffffffffffffffff81111561132457600080fd5b60208301915083602082850101111561133c57600080fd5b9250929050565b6000806000806060858703121561135957600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561137e57600080fd5b61138a878288016112fa565b95989497509550505050565b60008060008060008060a087890312156113af57600080fd5b86359550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156113e257600080fd5b6113ee89828a016112fa565b979a9699509497509295939492505050565b60006020828403121561141257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047057610470611419565b808202811582820484141761047057610470611419565b6000826114a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006040828403121561153b57600080fd5b6040516040810181811067ffffffffffffffff82111715611585577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b600060208083528351808285015260005b818110156115cc578581018301518582016040015282016115b0565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509291505056fea264697066735822122038f9f03f552b59eeabda9f604e46cf730b047f7ac321a71a3a6ef7a07151b77964736f6c63430008140033","runtime-code":"0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063a217fddf116100b2578063ccc5749011610081578063d547741f11610066578063d547741f14610390578063e4e06522146103a3578063efd07ec2146103b657600080fd5b8063ccc5749014610356578063cf4f578f1461037d57600080fd5b8063a217fddf14610315578063a87b81521461031d578063c473e7e814610330578063c4d66de81461034357600080fd5b80632f2ff15d116101095780635d62a8dd116100ee5780635d62a8dd1461021557806362014bad1461027357806391d14854146102b057600080fd5b80632f2ff15d146101ef57806336568abe1461020257600080fd5b806301ffc9a71461013b57806308c5c0db14610163578063248a9ca3146101985780632d54566c146101da575b600080fd5b61014e61014936600461122f565b6103dd565b60405190151581526020015b60405180910390f35b61018a7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb81565b60405190815260200161015a565b61018a6101a6366004611271565b60009081527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800602052604090206001015490565b6101ed6101e83660046112b3565b610476565b005b6101ed6101fd3660046112ce565b610587565b6101ed6102103660046112ce565b6105d1565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161015a565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31005473ffffffffffffffffffffffffffffffffffffffff1661024e565b61014e6102be3660046112ce565b60009182527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080842073ffffffffffffffffffffffffffffffffffffffff93909316845291905290205460ff1690565b61018a600081565b6101ed61032b3660046112b3565b61062f565b61018a61033e366004611343565b61075a565b6101ed6103513660046112b3565b610a3c565b61018a7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5581565b6101ed61038b366004611271565b610bbf565b6101ed61039e3660046112ce565b610c5f565b6101ed6103b1366004611396565b610ca3565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025461018a565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061047057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f556104a081610d60565b73ffffffffffffffffffffffffffffffffffffffff82166104ed576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811782556040519081527f4ab11d24f4bb323219ce90846ba579a556c914e8587517e7c8c4264771cd9f71906020015b60405180910390a1505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680060205260409020600101546105c181610d60565b6105cb8383610d6d565b50505050565b73ffffffffffffffffffffffffffffffffffffffff81163314610620576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062a8282610e8e565b505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f5561065981610d60565b73ffffffffffffffffffffffffffffffffffffffff82166106a6576040517f0a0c2d7000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e310180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091556040519081527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f3efbbb00c39812fb98647af6e9e2c3f4ec2b53d368cedd1e148330a05b652cfa9060200161057a565b60008061079b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31015473ffffffffffffffffffffffffffffffffffffffff1690565b905073ffffffffffffffffffffffffffffffffffffffff81166107ea576040517f38d2192500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006107f68585610f6c565b9050600161ffff82161115610842576040517f05e98f3a00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b600061088386868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610fb692505050565b80516040517f5cbd3c48000000000000000000000000000000000000000000000000000000008152600481018b905260248101919091526044810189905290915073ffffffffffffffffffffffffffffffffffffffff841690635cbd3c4890606401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190611400565b6020820151909450156109e15760208101516040517f1e7b928700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff851691631e7b928791610993918c91600401918252602082015260400190565b602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190611400565b6109de9085611448565b93505b670de0b6b3a7640000610a127fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31025490565b610a1c908661145b565b610a269190611472565b610a309085611448565b98975050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610a875750825b905060008267ffffffffffffffff166001148015610aa45750303b155b905081158015610ab2575080155b15610ae9576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b4a5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b55600087610d6d565b508315610bb75784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b7f7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55610be981610d60565b7fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e31028290556040518281527fabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100907f1957a4f563f2f13a7e7c1f9d8d6e719a1e6f687ac787704c33069f0a7997d75d9060200161057a565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020526040902060010154610c9981610d60565b6105cb8383610e8e565b7f506033f42d439a89b8dbacb157256b8ef7e613d9e48db1be101b85411778abfb610ccd81610d60565b6000610cdb8888868661075a565b905080851015610d21576040517f4641246a0000000000000000000000000000000000000000000000000000000081526004810186905260248101829052604401610839565b60405133815286907f507e9bdb8950e371753b8570704cf098fb0d67ca247f09a0629971ac80bd13829060200160405180910390a25050505050505050565b610d6a813361103f565b50565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff16610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff87168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610e203390565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610470565b6000915050610470565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020818152604080842073ffffffffffffffffffffffffffffffffffffffff8616855290915282205460ff1615610e845760008481526020828152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610470565b60006002821015610fad5782826040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016108399291906114ad565b50503560f01c90565b60408051808201909152600080825260208201526000610fd5836110ea565b9050600161ffff8216101561101c576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff82166004820152602401610839565b61102583611135565b8060200190518101906110389190611529565b9392505050565b60008281527f02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268006020908152604080832073ffffffffffffffffffffffffffffffffffffffff8516845290915290205460ff166110e6576040517fe2517d3f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8216600482015260248101839052604401610839565b5050565b600060028251101561112a57816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b506020015160f01c90565b606060028251101561117557816040517f659cf9fa000000000000000000000000000000000000000000000000000000008152600401610839919061159f565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156111b2576111b26114fa565b6040519080825280601f01601f1916602001820160405280156111dc576020820181803683370190505b50915060008160208401836022870160045afa905080611228576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561124157600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461103857600080fd5b60006020828403121561128357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff811681146112ae57600080fd5b919050565b6000602082840312156112c557600080fd5b6110388261128a565b600080604083850312156112e157600080fd5b823591506112f16020840161128a565b90509250929050565b60008083601f84011261130c57600080fd5b50813567ffffffffffffffff81111561132457600080fd5b60208301915083602082850101111561133c57600080fd5b9250929050565b6000806000806060858703121561135957600080fd5b8435935060208501359250604085013567ffffffffffffffff81111561137e57600080fd5b61138a878288016112fa565b95989497509550505050565b60008060008060008060a087890312156113af57600080fd5b86359550602087013594506040870135935060608701359250608087013567ffffffffffffffff8111156113e257600080fd5b6113ee89828a016112fa565b979a9699509497509295939492505050565b60006020828403121561141257600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047057610470611419565b808202811582820484141761047057610470611419565b6000826114a8577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006040828403121561153b57600080fd5b6040516040810181811067ffffffffffffffff82111715611585577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052825181526020928301519281019290925250919050565b600060208083528351808285015260005b818110156115cc578581018301518582016040015282016115b0565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116850101925050509291505056fea264697066735822122038f9f03f552b59eeabda9f604e46cf730b047f7ac321a71a3a6ef7a07151b77964736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"40069:403:0:-:0;;;40146:180;;;;;;;;;-1:-1:-1;40230:42:0;28619:4;40261:10;40230;:42::i;:::-;-1:-1:-1;40282:37:0;35292:26;40308:10;40282;:37::i;:::-;;40069:403;;33526:387;33603:4;30157:14;;;29176:28;30157:14;;;;;;;;-1:-1:-1;;;;;30157:31:0;;;;;;;;;;;;33688:219;;33731:8;:14;;;;;;;;;;;-1:-1:-1;;;;;33731:31:0;;;;;;;;;:38;;-1:-1:-1;;33731:38:0;33765:4;33731:38;;;33815:12;25220:10;;25141:96;33815:12;-1:-1:-1;;;;;33788:40:0;33806:7;-1:-1:-1;;;;;33788:40:0;33800:4;33788:40;;;;;;;;;;33849:4;33842:11;;;;;33688:219;33891:5;33884:12;;;33526:387;;;;;:::o;40069:403::-;;;;;;;","srcMapRuntime":"40069:403:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;29699:202;;;;;;:::i;:::-;;:::i;:::-;;;516:14:1;;509:22;491:41;;479:2;464:18;29699:202:0;;;;;;;;35324:68;;35365:27;35324:68;;;;;689:25:1;;;677:2;662:18;35324:68:0;543:177:1;31015:191:0;;;;;;:::i;:::-;31080:7;31175:14;;;29176:28;31175:14;;;;;:24;;;;31015:191;35705:379;;;;;;:::i;:::-;;:::i;:::-;;31502:136;;;;;;:::i;:::-;;:::i;32604:245::-;;;;;;:::i;:::-;;:::i;39119:187::-;39288:11;;;;39119:187;;;1737:42:1;1725:55;;;1707:74;;1695:2;1680:18;39119:187:0;1561:226:1;38875:191:0;39807:45;39046:13;;;38875:191;;29988:207;;;;;;:::i;:::-;30065:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;;;;29988:207;28574:49;;28619:4;28574:49;;36137:365;;;;;;:::i;:::-;;:::i;37506:1325::-;;;;;;:::i;:::-;;:::i;35534:118::-;;;;;;:::i;:::-;;:::i;35252:66::-;;35292:26;35252:66;;36555:274;;;;;;:::i;:::-;;:::i;31918:138::-;;;;;;:::i;:::-;;:::i;36873:589::-;;;;;;:::i;:::-;;:::i;39359:193::-;39531:14;;39359:193;;29699:202;29784:4;29807:47;;;29822:32;29807:47;;:87;;-1:-1:-1;26485:25:0;26470:40;;;;29858:36;29800:94;29699:202;-1:-1:-1;;29699:202:0:o;35705:379::-;35292:26;29447:16;29458:4;29447:10;:16::i;:::-;35806:26:::1;::::0;::::1;35802:102;;35855:38;;;;;;;;;;;;;;35802:102;39807:45:::0;36006:28;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;36049::::1;::::0;1707:74:1;;;36049:28:0::1;::::0;1695:2:1;1680:18;36049:28:0::1;;;;;;;;35792:292;35705:379:::0;;:::o;31502:136::-;31080:7;31175:14;;;29176:28;31175:14;;;;;:24;;;29447:16;29458:4;29447:10;:16::i;:::-;31606:25:::1;31617:4;31623:7;31606:10;:25::i;:::-;;31502:136:::0;;;:::o;32604:245::-;32697:34;;;25220:10;32697:34;32693:102;;32754:30;;;;;;;;;;;;;;32693:102;32805:37;32817:4;32823:18;32805:11;:37::i;:::-;;32604:245;;:::o;36137:365::-;35292:26;29447:16;29458:4;29447:10;:16::i;:::-;36234:24:::1;::::0;::::1;36230:100;;36281:38;;;;;;;;;;;;;;36230:100;36432:11:::0;:24;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;36471::::1;::::0;1707:74:1;;;39807:45:0;;36471:24:::1;::::0;1695:2:1;1680:18;36471:24:0::1;1561:226:1::0;37506:1325:0;37689:20;37725:23;37751:11;39288;;;;;39119:187;37751:11;37725:37;-1:-1:-1;37776:29:0;;;37772:109;;37828:42;;;;;;;;;;;;;;37772:109;38040:14;38057:39;38088:7;;38057:30;:39::i;:::-;38040:56;-1:-1:-1;23164:1:0;38110:31;;;;38106:129;;;38164:60;;;;;3923:6:1;3911:19;;38164:60:0;;;3893:38:1;3866:18;;38164:60:0;;;;;;;;38106:129;38244:26;38273:35;38300:7;;38273:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;38273:26:0;;-1:-1:-1;;;38273:35:0:i;:::-;38451:18;;38333:188;;;;;;;;4144:25:1;;;4185:18;;;4178:34;;;;4228:18;;;4221:34;;;38451:18:0;;-1:-1:-1;38333:54:0;;;;;;4117:18:1;;38333:188:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;38535:20;;;;38318:203;;-1:-1:-1;38535:24:0;38531:233;;38718:20;;;;38591:162;;;;;:58;;;;;;:162;;38683:10;;38591:162;;4629:25:1;;;4685:2;4670:18;;4663:34;4617:2;4602:18;;4455:248;38591:162:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;38575:178;;;;:::i;:::-;;;38531:233;35237:8;38804:14;39531;;;39359:193;38804:14;38789:29;;:12;:29;:::i;:::-;:35;;;;:::i;:::-;38773:51;;;;:::i;:::-;;37506:1325;-1:-1:-1;;;;;;;;37506:1325:0:o;35534:118::-;21043:21;16475:15;;;;;;;16474:16;;16521:14;;16331:30;16899:16;;:34;;;;;16919:14;16899:34;16879:54;;16943:17;16963:11;:16;;16978:1;16963:16;:50;;;;-1:-1:-1;16991:4:0;16983:25;:30;16963:50;16943:70;;17029:12;17028:13;:30;;;;;17046:12;17045:13;17028:30;17024:91;;;17081:23;;;;;;;;;;;;;;17024:91;17124:18;;;;17141:1;17124:18;;;17152:67;;;;17186:22;;;;;;;;17152:67;35608:37:::1;28619:4;35639:5:::0;35608:10:::1;:37::i;:::-;;17243:14:::0;17239:101;;;17273:23;;;;;;17315:14;;-1:-1:-1;5632:50:1;;17315:14:0;;5620:2:1;5605:18;17315:14:0;;;;;;;17239:101;16265:1081;;;;;35534:118;:::o;36555:274::-;35292:26;29447:16;29458:4;29447:10;:16::i;:::-;36747:14;:30;;;36792::::1;::::0;689:25:1;;;39807:45:0;;36792:30:::1;::::0;677:2:1;662:18;36792:30:0::1;543:177:1::0;31918:138:0;31080:7;31175:14;;;29176:28;31175:14;;;;;:24;;;29447:16;29458:4;29447:10;:16::i;:::-;32023:26:::1;32035:4;32041:7;32023:11;:26::i;36873:589::-:0;35365:27;29447:16;29458:4;29447:10;:16::i;:::-;37137:19:::1;37159:51;37175:10;37187:13;37202:7;;37159:15;:51::i;:::-;37137:73;;37239:11;37224:12;:26;37220:151;;;37273:87;::::0;::::1;::::0;;::::1;::::0;::::1;4629:25:1::0;;;4670:18;;;4663:34;;;4602:18;;37273:87:0::1;4455:248:1::0;37220:151:0::1;37385:70;::::0;37443:10:::1;1707:74:1::0;;37420:13:0;;37385:70:::1;::::0;1695:2:1;1680:18;37385:70:0::1;;;;;;;37127:335;36873:589:::0;;;;;;;:::o;30404:103::-;30470:30;30481:4;25220:10;30470;:30::i;:::-;30404:103;:::o;33526:387::-;33603:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;33688:219;;33731:8;:14;;;;;;;;;;;:31;;;;;;;;;;:38;;;;33765:4;33731:38;;;33815:12;25220:10;;25141:96;33815:12;33788:40;;33806:7;33788:40;;33800:4;33788:40;;;;;;;;;;33849:4;33842:11;;;;;33688:219;33891:5;33884:12;;;;;34148:388;34226:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;34311:219;;;34387:5;34353:14;;;;;;;;;;;:31;;;;;;;;;;;:39;;;;;;34411:40;25220:10;;34353:14;;34411:40;;34387:5;34411:40;34472:4;34465:11;;;;;5026:425;5102:14;4403:1;5132:40;;5128:122;;;5222:16;;5195:44;;;;;;;;;;;;:::i;5128:122::-;-1:-1:-1;;5397:37:0;5392:3;5388:47;;5026:425::o;23389:599::-;-1:-1:-1;;;;;;;;;;;;;;;;;23484:14:0;23501:27;:4;:25;:27::i;:::-;23484:44;-1:-1:-1;23164:1:0;23542:20;;;;23538:95;;;23585:37;;;;;3923:6:1;3911:19;;23585:37:0;;;3893:38:1;3866:18;;23585:37:0;3749:188:1;23538:95:0;23940:27;:4;:25;:27::i;:::-;23929:52;;;;;;;;;;;;:::i;:::-;23922:59;23389:599;-1:-1:-1;;;23389:599:0:o;30637:197::-;30065:4;30157:14;;;29176:28;30157:14;;;;;;;;:31;;;;;;;;;;;;;30720:108;;30770:47;;;;;7199:42:1;7187:55;;30770:47:0;;;7169:74:1;7259:18;;;7252:34;;;7142:18;;30770:47:0;6995:297:1;30720:108:0;30637:197;;:::o;6127:496::-;6211:14;4403:1;6241:16;:23;:40;6237:122;;;6331:16;6304:44;;;;;;;;;;;:::i;6237:122::-;-1:-1:-1;6600:4:0;6578:27;6572:34;6567:3;6563:44;;6127:496::o;6937:1053::-;7021:20;4403:1;7057:16;:23;:40;7053:122;;;7147:16;7120:44;;;;;;;;;;;:::i;7053:122::-;7333:23;;:40;;;7403:17;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7403:17:0;;7393:27;;7544:8;7880:6;7873:4;7864:7;7860:18;7852:6;7845:4;7827:16;7823:27;7817:4;7810:5;7799:88;7792:95;;7911:3;7906:78;;7937:36;;;;;;;;;;;;;;7906:78;7043:947;;6937:1053;;;:::o;14:332:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;180:9;167:23;230:66;223:5;219:78;212:5;209:89;199:117;;312:1;309;302:12;725:180;784:6;837:2;825:9;816:7;812:23;808:32;805:52;;;853:1;850;843:12;805:52;-1:-1:-1;876:23:1;;725:180;-1:-1:-1;725:180:1:o;910:196::-;978:20;;1038:42;1027:54;;1017:65;;1007:93;;1096:1;1093;1086:12;1007:93;910:196;;;:::o;1111:186::-;1170:6;1223:2;1211:9;1202:7;1198:23;1194:32;1191:52;;;1239:1;1236;1229:12;1191:52;1262:29;1281:9;1262:29;:::i;1302:254::-;1370:6;1378;1431:2;1419:9;1410:7;1406:23;1402:32;1399:52;;;1447:1;1444;1437:12;1399:52;1483:9;1470:23;1460:33;;1512:38;1546:2;1535:9;1531:18;1512:38;:::i;:::-;1502:48;;1302:254;;;;;:::o;1792:347::-;1843:8;1853:6;1907:3;1900:4;1892:6;1888:17;1884:27;1874:55;;1925:1;1922;1915:12;1874:55;-1:-1:-1;1948:20:1;;1991:18;1980:30;;1977:50;;;2023:1;2020;2013:12;1977:50;2060:4;2052:6;2048:17;2036:29;;2112:3;2105:4;2096:6;2088;2084:19;2080:30;2077:39;2074:59;;;2129:1;2126;2119:12;2074:59;1792:347;;;;;:::o;2144:545::-;2232:6;2240;2248;2256;2309:2;2297:9;2288:7;2284:23;2280:32;2277:52;;;2325:1;2322;2315:12;2277:52;2361:9;2348:23;2338:33;;2418:2;2407:9;2403:18;2390:32;2380:42;;2473:2;2462:9;2458:18;2445:32;2500:18;2492:6;2489:30;2486:50;;;2532:1;2529;2522:12;2486:50;2571:58;2621:7;2612:6;2601:9;2597:22;2571:58;:::i;:::-;2144:545;;;;-1:-1:-1;2648:8:1;-1:-1:-1;;;;2144:545:1:o;3061:683::-;3167:6;3175;3183;3191;3199;3207;3260:3;3248:9;3239:7;3235:23;3231:33;3228:53;;;3277:1;3274;3267:12;3228:53;3313:9;3300:23;3290:33;;3370:2;3359:9;3355:18;3342:32;3332:42;;3421:2;3410:9;3406:18;3393:32;3383:42;;3472:2;3461:9;3457:18;3444:32;3434:42;;3527:3;3516:9;3512:19;3499:33;3555:18;3547:6;3544:30;3541:50;;;3587:1;3584;3577:12;3541:50;3626:58;3676:7;3667:6;3656:9;3652:22;3626:58;:::i;:::-;3061:683;;;;-1:-1:-1;3061:683:1;;-1:-1:-1;3061:683:1;;3703:8;;3061:683;-1:-1:-1;;;3061:683:1:o;4266:184::-;4336:6;4389:2;4377:9;4368:7;4364:23;4360:32;4357:52;;;4405:1;4402;4395:12;4357:52;-1:-1:-1;4428:16:1;;4266:184;-1:-1:-1;4266:184:1:o;4708:::-;4760:77;4757:1;4750:88;4857:4;4854:1;4847:15;4881:4;4878:1;4871:15;4897:125;4962:9;;;4983:10;;;4980:36;;;4996:18;;:::i;5027:168::-;5100:9;;;5131;;5148:15;;;5142:22;;5128:37;5118:71;;5169:18;;:::i;5200:274::-;5240:1;5266;5256:189;;5301:77;5298:1;5291:88;5402:4;5399:1;5392:15;5430:4;5427:1;5420:15;5256:189;-1:-1:-1;5459:9:1;;5200:274::o;5693:447::-;5850:2;5839:9;5832:21;5889:6;5884:2;5873:9;5869:18;5862:34;5946:6;5938;5933:2;5922:9;5918:18;5905:48;6002:1;5973:22;;;5997:2;5969:31;;;5962:42;;;;6056:2;6044:15;;;6061:66;6040:88;6025:104;6021:113;;5693:447;-1:-1:-1;5693:447:1:o;6145:184::-;6197:77;6194:1;6187:88;6294:4;6291:1;6284:15;6318:4;6315:1;6308:15;6334:656;6430:6;6483:2;6471:9;6462:7;6458:23;6454:32;6451:52;;;6499:1;6496;6489:12;6451:52;6532:2;6526:9;6574:2;6566:6;6562:15;6643:6;6631:10;6628:22;6607:18;6595:10;6592:34;6589:62;6586:242;;;6684:77;6681:1;6674:88;6785:4;6782:1;6775:15;6813:4;6810:1;6803:15;6586:242;6844:2;6837:22;6883:16;;6868:32;;6954:2;6939:18;;;6933:25;6916:15;;;6909:50;;;;-1:-1:-1;6875:6:1;6334:656;-1:-1:-1;6334:656:1:o;7297:605::-;7407:4;7436:2;7465;7454:9;7447:21;7497:6;7491:13;7540:6;7535:2;7524:9;7520:18;7513:34;7565:1;7575:140;7589:6;7586:1;7583:13;7575:140;;;7684:14;;;7680:23;;7674:30;7650:17;;;7669:2;7646:26;7639:66;7604:10;;7575:140;;;7579:3;7764:1;7759:2;7750:6;7739:9;7735:22;7731:31;7724:42;7893:2;7823:66;7818:2;7810:6;7806:15;7802:88;7791:9;7787:104;7783:113;7775:121;;;;7297:605;;;;:::o","abiDefinition":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"SynapseExecutionService__FeeAmountTooLow","type":"error"},{"inputs":[],"name":"SynapseExecutionService__GasOracleNotSet","type":"error"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"SynapseExecutionService__OptionsVersionNotSupported","type":"error"},{"inputs":[],"name":"SynapseExecutionService__ZeroAddress","type":"error"},{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"ExecutionRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executorEOA","type":"address"}],"name":"ExecutorEOASet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gasOracle","type":"address"}],"name":"GasOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"globalMarkup","type":"uint256"}],"name":"GlobalMarkupSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_CLIENT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gasOracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"executionFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"globalMarkup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executorEOA_","type":"address"}],"name":"setExecutorEOA","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gasOracle_","type":"address"}],"name":"setGasOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"globalMarkup_","type":"uint256"}],"name":"setGlobalMarkup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"gasOracle()":{"notice":"Address of the gas oracle used for estimating the gas cost of the transactions."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"globalMarkup()":{"notice":"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."},"setExecutorEOA(address)":{"notice":"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains."},"setGasOracle(address)":{"notice":"Allows the contract governor to set the address of the gas oracle."},"setGlobalMarkup(uint256)":{"notice":"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates."}},"notice":"This harness is supposed to be used IN TESTS ONLY.","version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"InvalidInitialization()":[{"details":"The contract is already initialized."}],"NotInitializing()":[{"details":"The contract is not initializing."}]},"events":{"Initialized(uint64)":{"details":"Triggered when the contract has been initialized or reinitialized."},"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidInitialization\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotInitializing\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"SynapseExecutionService__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__GasOracleNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"SynapseExecutionService__OptionsVersionNotSupported\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SynapseExecutionService__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"ExecutionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executorEOA\",\"type\":\"address\"}],\"name\":\"ExecutorEOASet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"gasOracle\",\"type\":\"address\"}],\"name\":\"GasOracleSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"globalMarkup\",\"type\":\"uint256\"}],\"name\":\"GlobalMarkupSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"version\",\"type\":\"uint64\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_CLIENT_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gasOracle\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"globalMarkup\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executorEOA_\",\"type\":\"address\"}],\"name\":\"setExecutorEOA\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"gasOracle_\",\"type\":\"address\"}],\"name\":\"setGasOracle\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"globalMarkup_\",\"type\":\"uint256\"}],\"name\":\"setGlobalMarkup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"InvalidInitialization()\":[{\"details\":\"The contract is already initialized.\"}],\"NotInitializing()\":[{\"details\":\"The contract is not initializing.\"}]},\"events\":{\"Initialized(uint64)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"},\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"gasOracle()\":{\"notice\":\"Address of the gas oracle used for estimating the gas cost of the transactions.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"globalMarkup()\":{\"notice\":\"The markup that the Execution Service charges on top of the GasOracle's gas cost estimates. Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle. The markup is denominated in Wei, 1e18 being 100%.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"},\"setExecutorEOA(address)\":{\"notice\":\"Allows the contract governor to set the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"setGasOracle(address)\":{\"notice\":\"Allows the contract governor to set the address of the gas oracle.\"},\"setGlobalMarkup(uint256)\":{\"notice\":\"Allows the contract governor to set the global markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\"}},\"notice\":\"This harness is supposed to be used IN TESTS ONLY.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"SynapseExecutionServiceV1Harness\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","GOVERNOR_ROLE()":"ccc57490","IC_CLIENT_ROLE()":"08c5c0db","executorEOA()":"62014bad","gasOracle()":"5d62a8dd","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","getRoleAdmin(bytes32)":"248a9ca3","globalMarkup()":"efd07ec2","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","initialize(address)":"c4d66de8","renounceRole(bytes32,address)":"36568abe","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522","revokeRole(bytes32,address)":"d547741f","setExecutorEOA(address)":"2d54566c","setGasOracle(address)":"a87b8152","setGlobalMarkup(uint256)":"cf4f578f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/SynapseExecutionServiceV1Harness.sol:VersionedPayloadLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122023cca83e88122e438334a2396d46ea948ce2e2e8150ba7b4a02e1b952f2655fb64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122023cca83e88122e438334a2396d46ea948ce2e2e8150ba7b4a02e1b952f2655fb64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/SynapseExecutionServiceEvents.sol\n\nabstract contract SynapseExecutionServiceEvents {\n event ExecutorEOASet(address executorEOA);\n event GasOracleSet(address gasOracle);\n event GlobalMarkupSet(uint256 globalMarkup);\n\n event ExecutionRequested(bytes32 indexed transactionId, address client);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IGasOracle.sol\n\ninterface IGasOracle {\n /// @notice Convert a value from the native token of a remote chain to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param value The value to convert.\n function convertRemoteValueToLocalUnits(uint256 remoteChainId, uint256 value) external view returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and convert it to the local native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInLocalUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n\n /// @notice Estimate the cost of execution a transaction on a remote chain,\n /// and return it as is in the remote chain's native token.\n /// @dev Will revert if no price is available for the remote chain.\n /// @param remoteChainId The chain id of the remote chain.\n /// @param gasLimit The gas limit of the transaction.\n /// @param calldataSize The size of the transaction calldata.\n function estimateTxCostInRemoteUnits(\n uint256 remoteChainId,\n uint256 gasLimit,\n uint256 calldataSize\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 \u0026\u0026 isTopLevelCall;\n bool construction = initialized == 1 \u0026\u0026 address(this).code.length == 0;\n\n if (!initialSetup \u0026\u0026 !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized \u003e= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n\n// contracts/interfaces/ISynapseExecutionServiceV1.sol\n\ninterface ISynapseExecutionServiceV1 is IExecutionService {\n error SynapseExecutionService__GasOracleNotSet();\n error SynapseExecutionService__FeeAmountTooLow(uint256 actual, uint256 required);\n error SynapseExecutionService__OptionsVersionNotSupported(uint16 version);\n error SynapseExecutionService__ZeroAddress();\n\n /// @notice Allows the contract governor to set the address of the EOA account that will be used\n /// to execute transactions on the remote chains.\n function setExecutorEOA(address executorEOA_) external;\n\n /// @notice Allows the contract governor to set the address of the gas oracle.\n function setGasOracle(address gasOracle_) external;\n\n /// @notice Allows the contract governor to set the global markup that the Execution Service charges\n /// on top of the GasOracle's gas cost estimates.\n function setGlobalMarkup(uint256 globalMarkup_) external;\n\n /// @notice Address of the gas oracle used for estimating the gas cost of the transactions.\n function gasOracle() external view returns (address);\n\n /// @notice The markup that the Execution Service charges on top of the GasOracle's gas cost estimates.\n /// Zero markup means that the Execution Service charges the exact gas cost estimated by the GasOracle.\n /// The markup is denominated in Wei, 1e18 being 100%.\n function globalMarkup() external view returns (uint256);\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165 {\n function __ERC165_init() internal onlyInitializing {\n }\n\n function __ERC165_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl\n struct AccessControlStorage {\n mapping(bytes32 role =\u003e RoleData) _roles;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.AccessControl\")) - 1)) \u0026 ~bytes32(uint256(0xff))\n bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;\n\n function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {\n assembly {\n $.slot := AccessControlStorageLocation\n }\n }\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n function __AccessControl_init() internal onlyInitializing {\n }\n\n function __AccessControl_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n return $._roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n AccessControlStorage storage $ = _getAccessControlStorage();\n bytes32 previousAdminRole = getRoleAdmin(role);\n $._roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (!hasRole(role, account)) {\n $._roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n AccessControlStorage storage $ = _getAccessControlStorage();\n if (hasRole(role, account)) {\n $._roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/execution/SynapseExecutionServiceV1.sol\n\ncontract SynapseExecutionServiceV1 is\n AccessControlUpgradeable,\n SynapseExecutionServiceEvents,\n ISynapseExecutionServiceV1\n{\n /// @custom:storage-location erc7201:Synapse.ExecutionService.V1\n struct SynapseExecutionServiceV1Storage {\n address executorEOA;\n address gasOracle;\n uint256 globalMarkup;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"Synapse.ExecutionService.V1\")) - 1)) \u0026 ~bytes32(uint256(0xff));\n bytes32 private constant SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION =\n 0xabc861e0f8da03757893d41bb54770e6953c799ce2884f80d6b14b66ba8e3100;\n uint256 private constant WAD = 10 ** 18;\n\n bytes32 public constant GOVERNOR_ROLE = keccak256(\"GOVERNOR_ROLE\");\n bytes32 public constant IC_CLIENT_ROLE = keccak256(\"IC_CLIENT_ROLE\");\n\n constructor() {\n // Ensure that the implementation contract could not be initialized\n _disableInitializers();\n }\n\n function initialize(address admin) external virtual initializer {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setExecutorEOA(address executorEOA_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (executorEOA_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.executorEOA = executorEOA_;\n emit ExecutorEOASet(executorEOA_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGasOracle(address gasOracle_) external virtual onlyRole(GOVERNOR_ROLE) {\n if (gasOracle_ == address(0)) {\n revert SynapseExecutionService__ZeroAddress();\n }\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.gasOracle = gasOracle_;\n emit GasOracleSet(gasOracle_);\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function setGlobalMarkup(uint256 globalMarkup_) external virtual onlyRole(GOVERNOR_ROLE) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n $.globalMarkup = globalMarkup_;\n emit GlobalMarkupSet(globalMarkup_);\n }\n\n /// @inheritdoc IExecutionService\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes calldata options\n )\n external\n virtual\n onlyRole(IC_CLIENT_ROLE)\n {\n uint256 requiredFee = getExecutionFee(dstChainId, txPayloadSize, options);\n if (executionFee \u003c requiredFee) {\n revert SynapseExecutionService__FeeAmountTooLow({actual: executionFee, required: requiredFee});\n }\n emit ExecutionRequested({transactionId: transactionId, client: msg.sender});\n }\n\n /// @inheritdoc IExecutionService\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes calldata options\n )\n public\n view\n virtual\n returns (uint256 executionFee)\n {\n address cachedGasOracle = gasOracle();\n if (cachedGasOracle == address(0)) {\n revert SynapseExecutionService__GasOracleNotSet();\n }\n // ExecutionServiceV1 implementation only supports Options V1.\n // Following versions will be supported by the future implementations.\n uint16 version = VersionedPayloadLib.getVersion(options);\n if (version \u003e OptionsLib.OPTIONS_V1) {\n revert SynapseExecutionService__OptionsVersionNotSupported(version);\n }\n OptionsV1 memory optionsV1 = OptionsLib.decodeOptionsV1(options);\n executionFee = IGasOracle(cachedGasOracle).estimateTxCostInLocalUnits({\n remoteChainId: dstChainId,\n gasLimit: optionsV1.gasLimit,\n calldataSize: txPayloadSize\n });\n if (optionsV1.gasAirdrop \u003e 0) {\n executionFee += IGasOracle(cachedGasOracle).convertRemoteValueToLocalUnits({\n remoteChainId: dstChainId,\n value: optionsV1.gasAirdrop\n });\n }\n executionFee += executionFee * globalMarkup() / WAD;\n }\n\n /// @inheritdoc IExecutionService\n function executorEOA() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.executorEOA;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function gasOracle() public view virtual returns (address) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.gasOracle;\n }\n\n /// @inheritdoc ISynapseExecutionServiceV1\n function globalMarkup() public view virtual returns (uint256) {\n SynapseExecutionServiceV1Storage storage $ = _getSynapseExecutionServiceV1Storage();\n return $.globalMarkup;\n }\n\n /// @dev ERC-7201 slot accessor\n function _getSynapseExecutionServiceV1Storage() private pure returns (SynapseExecutionServiceV1Storage storage $) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n $.slot := SYNAPSE_EXECUTION_SERVICE_V1_STORAGE_LOCATION\n }\n }\n}\n\n// test/harnesses/SynapseExecutionServiceV1Harness.sol\n\n// solhint-disable no-empty-blocks\n/// @notice This harness is supposed to be used IN TESTS ONLY.\n// DO NOT use this contract in production.\ncontract SynapseExecutionServiceV1Harness is SynapseExecutionServiceV1 {\n constructor() {\n // Grant the deployer all roles to simplify testing\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(GOVERNOR_ROLE, msg.sender);\n }\n\n function _disableInitializers() internal override {\n // No-op so that we can use the implementation w/o the proxy in Go tests\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"4235:3757:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;4235:3757:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"4235:3757:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":\"VersionedPayloadLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/SynapseExecutionServiceV1Harness.sol\":{\"keccak256\":\"0xe2cad9ba746afac6a1894800771b0c0b52aca21e389c9ae7f21816b12273139d\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3bc84810b56e2620953369568186eab0be2cd9cf01c11298d9d0275285573e82\",\"dweb:/ipfs/QmeenMEGcRr3XAM4D4twGPiB3nfTp3RTu1sxbtMVFJpYzE\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file diff --git a/sin-executor/contracts/interchainclient/interchainclient.abigen.go b/sin-executor/contracts/interchainclient/interchainclient.abigen.go index ce74755cfd..bba2c71e6f 100644 --- a/sin-executor/contracts/interchainclient/interchainclient.abigen.go +++ b/sin-executor/contracts/interchainclient/interchainclient.abigen.go @@ -72,8 +72,8 @@ type OptionsV1 struct { // AppConfigLibMetaData contains all meta data concerning the AppConfigLib contract. var AppConfigLibMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220783dec0d3097ec4bb618b65c167149ccd1cb9539620af566d8d5b2c20a341ebd64736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122012d05505a05b58970134f05a99b51c118a09086c491bbfb5706f3ae8d93f6fa764736f6c63430008140033", } // AppConfigLibABI is the input ABI used to generate the binding from. @@ -2276,7 +2276,7 @@ func (_IInterchainDB *IInterchainDBTransactorSession) WriteEntryWithVerification // InterchainBatchLibMetaData contains all meta data concerning the InterchainBatchLib contract. var InterchainBatchLibMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a7165588fec5b6b13f17833c19ba7286717f3c1019c9e7ab8acbad3da0a717b364736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d78f7327549c020b1c36cf7060e7190a3a38d9835007bebfdfcf92ad7488691464736f6c63430008140033", } // InterchainBatchLibABI is the input ABI used to generate the binding from. @@ -2448,7 +2448,7 @@ func (_InterchainBatchLib *InterchainBatchLibTransactorRaw) Transact(opts *bind. // InterchainClientV1MetaData contains all meta data concerning the InterchainClientV1 contract. var InterchainClientV1MetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"interchainDB\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionFees\",\"type\":\"address\"}],\"name\":\"ExecutionFeesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionProofWritten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"}],\"name\":\"InterchainTransactionReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"verificationFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"InterchainTransactionSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"LinkedClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"INTERCHAIN_DB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedOptions\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"structOptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structInterchainTransaction\",\"name\":\"icTx\",\"type\":\"tuple\"}],\"name\":\"encodeTransaction\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executionFees\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedClientEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"interchainDB\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionFees\",\"type\":\"address\"}],\"name\":\"ExecutionFeesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionProofWritten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"}],\"name\":\"InterchainTransactionReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"verificationFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"InterchainTransactionSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"LinkedClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"INTERCHAIN_DB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedOptions\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"structOptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structInterchainTransaction\",\"name\":\"icTx\",\"type\":\"tuple\"}],\"name\":\"encodeTransaction\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executionFees\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedClientEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"structInterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", Sigs: map[string]string{ "e4c61247": "INTERCHAIN_DB()", "d5e788a0": "decodeOptions(bytes)", @@ -2470,7 +2470,7 @@ var InterchainClientV1MetaData = &bind.MetaData{ "f2fde38b": "transferOwnership(address)", "90e81077": "writeExecutionProof(bytes32)", }, - Bin: "0x60a06040523480156200001157600080fd5b5060405162002b0438038062002b048339810160408190526200003491620000f0565b806001600160a01b0381166200006457604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b6200006f8162000083565b50506001600160a01b031660805262000128565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000eb57600080fd5b919050565b600080604083850312156200010457600080fd5b6200010f83620000d3565b91506200011f60208401620000d3565b90509250929050565b6080516129966200016e600039600081816103bd015281816108af01528181610b46015281816113ce0152818161148f015281816115ed0152611a8c01526129966000f3fe6080604052600436106101445760003560e01c80638da5cb5b116100c0578063e4c6124711610074578063f2fde38b11610059578063f2fde38b14610422578063f34234c814610442578063f92a79ff1461046257600080fd5b8063e4c61247146103ab578063f1a61fac146103df57600080fd5b806398939d28116100a557806398939d281461033d578063aa102ec414610350578063d5e788a01461037057600080fd5b80638da5cb5b146102d457806390e81077146102ff57600080fd5b8063715018a6116101175780637a1277db116100fc5780637a1277db1461023a5780637c80a90f14610268578063827f940d1461029557600080fd5b8063715018a6146101f85780637341eaf91461020d57600080fd5b806302172a35146101495780631450c281146101935780633dc68b87146101c357806353b67d74146101e5575b600080fd5b34801561015557600080fd5b50610169610164366004611c4d565b610482565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561019f57600080fd5b506101b36101ae366004611cf4565b61052e565b604051901515815260200161018a565b3480156101cf57600080fd5b506101e36101de366004611d82565b610598565b005b6101e36101f3366004611d9f565b610619565b34801561020457600080fd5b506101e3610812565b34801561021957600080fd5b506001546101699073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024657600080fd5b5061025a610255366004611e19565b610826565b60405190815260200161018a565b34801561027457600080fd5b50610288610283366004611fd7565b610a08565b60405161018a91906120fc565b6102a86102a336600461210f565b610a19565b6040805182518152602080840151908201529181015167ffffffffffffffff169082015260600161018a565b3480156102e057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610169565b34801561030b57600080fd5b5061031f61031a366004611c4d565b610a6d565b6040805192835267ffffffffffffffff90911660208301520161018a565b6102a861034b3660046121da565b610c2c565b34801561035c57600080fd5b5061025a61036b366004611c4d565b610c68565b34801561037c57600080fd5b5061039061038b366004612211565b610cb9565b6040805182518152602092830151928101929092520161018a565b3480156103b757600080fd5b506101697f000000000000000000000000000000000000000000000000000000000000000081565b3480156103eb57600080fd5b506101696103fa366004611c4d565b60009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b34801561042e57600080fd5b506101e361043d366004611d82565b610cd6565b34801561044e57600080fd5b506101e361045d366004612246565b610d3a565b34801561046e57600080fd5b5061016961047d366004612268565b610d91565b60004682036104c5576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b506000818152600260205260409020548073ffffffffffffffffffffffffffffffffffffffff81168114610528576040517f0a55a4eb000000000000000000000000000000000000000000000000000000008152600481018290526024016104bc565b50919050565b60008061057086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905061057f8160c00151610e7d565b5061058b818585610f01565b5060019695505050505050565b6105a061113c565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fec02f15d78cdfc4beeba45f31cfad25089004e5e3d72727168dd96a77d1f2f829060200160405180910390a150565b600061065a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b90506000610669828585610f01565b600081815260036020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317905560c0840151919250906106b190610e7d565b9050806020015134146106ff5760208101516040517f2b36102500000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016104bc565b805188101561070d57805197505b606083015173ffffffffffffffffffffffffffffffffffffffff166368a6984789348660000151876020015188608001518960a001518a60e001516040518863ffffffff1660e01b81526004016107689594939291906122aa565b6000604051808303818589803b15801561078157600080fd5b5088f1158015610795573d6000803e3d6000fd5b5050505050508260a0015167ffffffffffffffff168360800151837f9c887f38b8f2330ee9894137eb60cf6ab904c5d2063ddc0baa7a77bfd1880e8c866000015187602001518860600151604051610800939291909283526020830191909152604082015260600190565b60405180910390a45050505050505050565b61081a61113c565b610824600061118f565b565b600061083188611204565b5061087184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec906108e8908b908a908a90600401612335565b602060405180830381865afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109299190612358565b905073ffffffffffffffffffffffffffffffffffffffff8716156109fd5760006109538484611294565b6040517fc473e7e800000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff89169063c473e7e8906109ae908c9085908a908a9060040161239c565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190612358565b6109f990836123f5565b9150505b979650505050505050565b6060610a13826112c3565b92915050565b604080516060810182526000808252602082018190529181019190915273ffffffffffffffffffffffffffffffffffffffff8916610a5e8b828b8b8b8b8b8b8b6112ec565b9b9a5050505050505050505050565b600081815260036020526040812054819073ffffffffffffffffffffffffffffffffffffffff1680610ace576040517fe99eb48d000000000000000000000000000000000000000000000000000000008152600481018590526024016104bc565b60008482604051602001610b0292919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60408051808303601f1901815290829052805160208201207f2ad8c706000000000000000000000000000000000000000000000000000000008352600483015291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632ad8c7069060240160408051808303816000875af1158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc79190612413565b60405173ffffffffffffffffffffffffffffffffffffffff85168152919550935067ffffffffffffffff841690859087907f810ecf3e461a7f5c46c0bbbca8680cf65de59e78e521d58d569e03969d08648c9060200160405180910390a45050915091565b6040805160608101825260008082526020820181905291810191909152610c5a8a8a8a8a8a8a8a8a8a6112ec565b9a9950505050505050505050565b6000468203610ca6576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060009081526002602052604090205490565b6040805180820190915260008082526020820152610a1382610e7d565b610cde61113c565b73ffffffffffffffffffffffffffffffffffffffff8116610d2e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016104bc565b610d378161118f565b50565b610d4261113c565b60008281526002602090815260409182902083905581518481529081018390527fb6b5dc04cc1c35fc7a8c8342e378dccc610c6589ef3bcfcd6eaf0304913f889a910160405180910390a15050565b600080610dd384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905060036000610de2836119c1565b815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16949350505050565b610e696040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b81806020019051810190610a139190612488565b6040805180820190915260008082526020820152600080610e9d846119f1565b9092509050600160ff83161015610ee5576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff831660048201526024016104bc565b80806020019051810190610ef9919061259d565b949350505050565b600080610f118560000151611204565b905046856040015114610f585784604001516040517f973253820000000000000000000000000000000000000000000000000000000081526004016104bc91815260200190565b610f61856119c1565b60008181526003602052604090205490925073ffffffffffffffffffffffffffffffffffffffff1615610fc3576040517fd80aeb91000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b60006040518060a0016040528087600001518152602001876080015181526020018760a0015167ffffffffffffffff168152602001838152602001848152509050600080611012886060015190565b73ffffffffffffffffffffffffffffffffffffffff1663287bc0576040518163ffffffff1660e01b8152600401600060405180830381865afa15801561105c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261108491908101906125b9565b91509150600061109383611a13565b80519091506000036110d1576040517fa09e214300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006110e483868b8b8660200151611a7b565b825190915081101561112f5781516040517f0bce4e850000000000000000000000000000000000000000000000000000000081526104bc918391600401918252602082015260400190565b5050505050509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610824576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104bc565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000468203611242576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b506000818152600260205260408120549081900361128f576040517f9a45110f000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b919050565b6000601f19601f830116601f19601f8501166112b2906101606123f5565b6112bc91906123f5565b9392505050565b6060816040516020016112d6919061268f565b6040516020818303038152906040529050919050565b60408051606081018252600080825260208201819052918101919091526113128a611204565b50600089900361134e576040517f0b3e41a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61138d85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec90611407908e908c908c90600401612335565b602060405180830381865afa158015611424573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114489190612358565b90508034101561148d576040517f9557ee49000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016104bc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aa2f06ae6040518163ffffffff1660e01b81526004016040805180830381865afa1580156114f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151b9190612413565b83602001846040018267ffffffffffffffff1667ffffffffffffffff1681525082815250505060006115d4338d8d866020015187604001518c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b8892505050565b90506115df816119c1565b8360000181815250506000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367c769af85856040015188600001518f8f6040518663ffffffff1660e01b81526004016116539493929190612710565b604080518083038185885af1158015611670573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116959190612413565b915091508460200151821480156116c35750846040015167ffffffffffffffff168167ffffffffffffffff16145b6116cf576116cf612730565b50503482810390831461177857600154604080840151865191517fffecec7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263ffecec7e92859261174592909190600401918252602082015260400190565b6000604051808303818588803b15801561175e57600080fd5b505af1158015611772573d6000803e3d6000fd5b50505050505b73ffffffffffffffffffffffffffffffffffffffff8b16156119415773ffffffffffffffffffffffffffffffffffffffff8b1663e4e065228e6117bb8a89611294565b87516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526117fe9392919087908f908f9060040161275f565b600060405180830381600087803b15801561181857600080fd5b505af115801561182c573d6000803e3d6000fd5b5050505060008b73ffffffffffffffffffffffffffffffffffffffff166362014bad6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561187d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a19190612797565b600154604085810151885191517f0676b7060000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915273ffffffffffffffffffffffffffffffffffffffff8084166044830152929350911690630676b70690606401600060405180830381600087803b15801561192757600080fd5b505af115801561193b573d6000803e3d6000fd5b50505050505b8160a0015167ffffffffffffffff16826080015185600001517f1b22d6c0b67f6f17a9004833bfb5afbaea4602457bd57e1d128cb997fb30161b85604001518660200151876060015189888a60c001518b60e001516040516119a997969594939291906127b4565b60405180910390a45050509998505050505050505050565b6000816040516020016119d4919061268f565b604051602081830303815290604052805190602001209050919050565b6000606082806020019051810190611a0991906127f7565b9094909350915050565b6040805180820190915260008082526020820152600080611a33846119f1565b9092509050600160ff83161015610ee5576040517fc3e3b66600000000000000000000000000000000000000000000000000000000815260ff831660048201526024016104bc565b6000805b8651811015611b7e5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367b1f42e898481518110611ad857611ad861284e565b60200260200101518989896040518563ffffffff1660e01b8152600401611b02949392919061287d565b602060405180830381865afa158015611b1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b439190612358565b90508015801590611b5c575042611b5a85836123f5565b105b15611b6d57611b6a83612928565b92505b50611b7781612928565b9050611a7f565b5095945050505050565b611be06040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b604051806101000160405280468152602001611c0f8a73ffffffffffffffffffffffffffffffffffffffff1690565b81526020018881526020018781526020018681526020018567ffffffffffffffff168152602001848152602001838152509050979650505050505050565b600060208284031215611c5f57600080fd5b5035919050565b60008083601f840112611c7857600080fd5b50813567ffffffffffffffff811115611c9057600080fd5b602083019150836020828501011115611ca857600080fd5b9250929050565b60008083601f840112611cc157600080fd5b50813567ffffffffffffffff811115611cd957600080fd5b6020830191508360208260051b8501011115611ca857600080fd5b60008060008060408587031215611d0a57600080fd5b843567ffffffffffffffff80821115611d2257600080fd5b611d2e88838901611c66565b90965094506020870135915080821115611d4757600080fd5b50611d5487828801611caf565b95989497509550505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d3757600080fd5b600060208284031215611d9457600080fd5b81356112bc81611d60565b600080600080600060608688031215611db757600080fd5b85359450602086013567ffffffffffffffff80821115611dd657600080fd5b611de289838a01611c66565b90965094506040880135915080821115611dfb57600080fd5b50611e0888828901611caf565b969995985093965092949392505050565b600080600080600080600060a0888a031215611e3457600080fd5b873596506020880135611e4681611d60565b9550604088013567ffffffffffffffff80821115611e6357600080fd5b611e6f8b838c01611caf565b909750955060608a0135915080821115611e8857600080fd5b50611e958a828b01611c66565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff81118282101715611f0157611f01611eae565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611f3057611f30611eae565b604052919050565b67ffffffffffffffff81168114610d3757600080fd5b803561128f81611f38565b600067ffffffffffffffff821115611f7357611f73611eae565b50601f01601f191660200190565b600082601f830112611f9257600080fd5b8135611fa5611fa082611f59565b611f07565b818152846020838601011115611fba57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215611fe957600080fd5b813567ffffffffffffffff8082111561200157600080fd5b90830190610100828603121561201657600080fd5b61201e611edd565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015261205660a08401611f4e565b60a082015260c08301358281111561206d57600080fd5b61207987828601611f81565b60c08301525060e08301358281111561209157600080fd5b61209d87828601611f81565b60e08301525095945050505050565b60005b838110156120c75781810151838201526020016120af565b50506000910152565b600081518084526120e88160208601602086016120ac565b601f01601f19169290920160200192915050565b6020815260006112bc60208301846120d0565b600080600080600080600080600060c08a8c03121561212d57600080fd5b8935985060208a013561213f81611d60565b975060408a013561214f81611d60565b965060608a013567ffffffffffffffff8082111561216c57600080fd5b6121788d838e01611caf565b909850965060808c013591508082111561219157600080fd5b61219d8d838e01611c66565b909650945060a08c01359150808211156121b657600080fd5b506121c38c828d01611c66565b915080935050809150509295985092959850929598565b600080600080600080600080600060c08a8c0312156121f857600080fd5b8935985060208a0135975060408a013561214f81611d60565b60006020828403121561222357600080fd5b813567ffffffffffffffff81111561223a57600080fd5b610ef984828501611f81565b6000806040838503121561225957600080fd5b50508035926020909101359150565b6000806020838503121561227b57600080fd5b823567ffffffffffffffff81111561229257600080fd5b61229e85828601611c66565b90969095509350505050565b85815284602082015283604082015267ffffffffffffffff8316606082015260a0608082015260006109fd60a08301846120d0565b8183526000602080850194508260005b8581101561232a57813561230281611d60565b73ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016122ef565b509495945050505050565b83815260406020820152600061234f6040830184866122df565b95945050505050565b60006020828403121561236a57600080fd5b5051919050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b8481528360208201526060604082015260006123bc606083018486612371565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610a1357610a136123c6565b805161128f81611f38565b6000806040838503121561242657600080fd5b82519150602083015161243881611f38565b809150509250929050565b600082601f83011261245457600080fd5b8151612462611fa082611f59565b81815284602083860101111561247757600080fd5b610ef98260208301602087016120ac565b60006020828403121561249a57600080fd5b815167ffffffffffffffff808211156124b257600080fd5b9083019061010082860312156124c757600080fd5b6124cf611edd565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015261250760a08401612408565b60a082015260c08301518281111561251e57600080fd5b61252a87828601612443565b60c08301525060e08301518281111561254257600080fd5b61209d87828601612443565b60006040828403121561256057600080fd5b6040516040810181811067ffffffffffffffff8211171561258357612583611eae565b604052825181526020928301519281019290925250919050565b6000604082840312156125af57600080fd5b6112bc838361254e565b600080604083850312156125cc57600080fd5b825167ffffffffffffffff808211156125e457600080fd5b6125f086838701612443565b935060209150818501518181111561260757600080fd5b8501601f8101871361261857600080fd5b80518281111561262a5761262a611eae565b8060051b925061263b848401611f07565b818152928201840192848101908985111561265557600080fd5b928501925b8484101561267f578351925061266f83611d60565b828252928501929085019061265a565b8096505050505050509250929050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015267ffffffffffffffff60a08301511660c0820152600060c08301516101008060e08501526126f46101208501836120d0565b915060e0850151601f1985840301828601526123bc83826120d0565b8481528360208201526060604082015260006123bc6060830184866122df565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b86815285602082015284604082015283606082015260a06080820152600061278b60a083018486612371565b98975050505050505050565b6000602082840312156127a957600080fd5b81516112bc81611d60565b87815286602082015285604082015284606082015283608082015260e060a082015260006127e560e08301856120d0565b82810360c0840152610c5a81856120d0565b6000806040838503121561280a57600080fd5b825160ff8116811461281b57600080fd5b602084015190925067ffffffffffffffff81111561283857600080fd5b61284485828601612443565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff85168152835160208201526020840151604082015267ffffffffffffffff604085015116606082015260608401516080820152608084015160a082015260e060c08201528160e082015260006101007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84111561290e57600080fd5b8360051b8086838601379290920190910195945050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612959576129596123c6565b506001019056fea264697066735822122091c22b0cc90fb32367eac5ecf5fc611ddfc546d213efc6b396bcb06086bbe0b564736f6c63430008140033", + Bin: "0x60a06040523480156200001157600080fd5b5060405162002bd438038062002bd48339810160408190526200003491620000f0565b806001600160a01b0381166200006457604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b6200006f8162000083565b50506001600160a01b031660805262000128565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000eb57600080fd5b919050565b600080604083850312156200010457600080fd5b6200010f83620000d3565b91506200011f60208401620000d3565b90509250929050565b608051612a666200016e600039600081816103bd015281816108af01528181610b46015281816113cc0152818161148d015281816115eb0152611bab0152612a666000f3fe6080604052600436106101445760003560e01c80638da5cb5b116100c0578063e4c6124711610074578063f2fde38b11610059578063f2fde38b14610422578063f34234c814610442578063f92a79ff1461046257600080fd5b8063e4c61247146103ab578063f1a61fac146103df57600080fd5b806398939d28116100a557806398939d281461033d578063aa102ec414610350578063d5e788a01461037057600080fd5b80638da5cb5b146102d457806390e81077146102ff57600080fd5b8063715018a6116101175780637a1277db116100fc5780637a1277db1461023a5780637c80a90f14610268578063827f940d1461029557600080fd5b8063715018a6146101f85780637341eaf91461020d57600080fd5b806302172a35146101495780631450c281146101935780633dc68b87146101c357806353b67d74146101e5575b600080fd5b34801561015557600080fd5b50610169610164366004611d6c565b610482565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561019f57600080fd5b506101b36101ae366004611e13565b61052e565b604051901515815260200161018a565b3480156101cf57600080fd5b506101e36101de366004611ea1565b610598565b005b6101e36101f3366004611ebe565b610619565b34801561020457600080fd5b506101e3610812565b34801561021957600080fd5b506001546101699073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024657600080fd5b5061025a610255366004611f38565b610826565b60405190815260200161018a565b34801561027457600080fd5b506102886102833660046120f6565b610a08565b60405161018a919061221b565b6102a86102a336600461222e565b610a19565b6040805182518152602080840151908201529181015167ffffffffffffffff169082015260600161018a565b3480156102e057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610169565b34801561030b57600080fd5b5061031f61031a366004611d6c565b610a6d565b6040805192835267ffffffffffffffff90911660208301520161018a565b6102a861034b3660046122f9565b610c2c565b34801561035c57600080fd5b5061025a61036b366004611d6c565b610c68565b34801561037c57600080fd5b5061039061038b366004612330565b610cb9565b6040805182518152602092830151928101929092520161018a565b3480156103b757600080fd5b506101697f000000000000000000000000000000000000000000000000000000000000000081565b3480156103eb57600080fd5b506101696103fa366004611d6c565b60009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b34801561042e57600080fd5b506101e361043d366004611ea1565b610cd6565b34801561044e57600080fd5b506101e361045d36600461236d565b610d3a565b34801561046e57600080fd5b5061016961047d36600461238f565b610d91565b60004682036104c5576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b506000818152600260205260409020548073ffffffffffffffffffffffffffffffffffffffff81168114610528576040517f0a55a4eb000000000000000000000000000000000000000000000000000000008152600481018290526024016104bc565b50919050565b60008061057086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905061057f8160c00151610e7d565b5061058b818585610f06565b5060019695505050505050565b6105a0611141565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fec02f15d78cdfc4beeba45f31cfad25089004e5e3d72727168dd96a77d1f2f829060200160405180910390a150565b600061065a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b90506000610669828585610f06565b600081815260036020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317905560c0840151919250906106b190610e7d565b9050806020015134146106ff5760208101516040517f2b36102500000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016104bc565b805188101561070d57805197505b606083015173ffffffffffffffffffffffffffffffffffffffff166368a6984789348660000151876020015188608001518960a001518a60e001516040518863ffffffff1660e01b81526004016107689594939291906123d1565b6000604051808303818589803b15801561078157600080fd5b5088f1158015610795573d6000803e3d6000fd5b5050505050508260a0015167ffffffffffffffff168360800151837f9c887f38b8f2330ee9894137eb60cf6ab904c5d2063ddc0baa7a77bfd1880e8c866000015187602001518860600151604051610800939291909283526020830191909152604082015260600190565b60405180910390a45050505050505050565b61081a611141565b6108246000611194565b565b600061083188611209565b5061087184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec906108e8908b908a908a9060040161245c565b602060405180830381865afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610929919061247f565b905073ffffffffffffffffffffffffffffffffffffffff8716156109fd5760006109538484611299565b6040517fc473e7e800000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff89169063c473e7e8906109ae908c9085908a908a906004016124c3565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef919061247f565b6109f9908361251c565b9150505b979650505050505050565b6060610a13826112c1565b92915050565b604080516060810182526000808252602082018190529181019190915273ffffffffffffffffffffffffffffffffffffffff8916610a5e8b828b8b8b8b8b8b8b6112ea565b9b9a5050505050505050505050565b600081815260036020526040812054819073ffffffffffffffffffffffffffffffffffffffff1680610ace576040517fe99eb48d000000000000000000000000000000000000000000000000000000008152600481018590526024016104bc565b60008482604051602001610b0292919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60408051808303601f1901815290829052805160208201207f2ad8c706000000000000000000000000000000000000000000000000000000008352600483015291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632ad8c7069060240160408051808303816000875af1158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc7919061253a565b60405173ffffffffffffffffffffffffffffffffffffffff85168152919550935067ffffffffffffffff841690859087907f810ecf3e461a7f5c46c0bbbca8680cf65de59e78e521d58d569e03969d08648c9060200160405180910390a45050915091565b6040805160608101825260008082526020820181905291810191909152610c5a8a8a8a8a8a8a8a8a8a6112ea565b9a9950505050505050505050565b6000468203610ca6576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060009081526002602052604090205490565b6040805180820190915260008082526020820152610a1382610e7d565b610cde611141565b73ffffffffffffffffffffffffffffffffffffffff8116610d2e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016104bc565b610d3781611194565b50565b610d42611141565b60008281526002602090815260409182902083905581518481529081018390527fb6b5dc04cc1c35fc7a8c8342e378dccc610c6589ef3bcfcd6eaf0304913f889a910160405180910390a15050565b600080610dd384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905060036000610de2836119bf565b815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16949350505050565b610e696040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b81806020019051810190610a1391906125af565b60408051808201909152600080825260208201526000610e9c836119ef565b9050600161ffff82161015610ee3576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff821660048201526024016104bc565b610eec83611a3a565b806020019051810190610eff91906126c4565b9392505050565b600080610f168560000151611209565b905046856040015114610f5d5784604001516040517f973253820000000000000000000000000000000000000000000000000000000081526004016104bc91815260200190565b610f66856119bf565b60008181526003602052604090205490925073ffffffffffffffffffffffffffffffffffffffff1615610fc8576040517fd80aeb91000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b60006040518060a0016040528087600001518152602001876080015181526020018760a0015167ffffffffffffffff168152602001838152602001848152509050600080611017886060015190565b73ffffffffffffffffffffffffffffffffffffffff1663287bc0576040518163ffffffff1660e01b8152600401600060405180830381865afa158015611061573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261108991908101906126e0565b91509150600061109883611b34565b80519091506000036110d6576040517fa09e214300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006110e983868b8b8660200151611b9a565b82519091508110156111345781516040517f0bce4e850000000000000000000000000000000000000000000000000000000081526104bc918391600401918252602082015260400190565b5050505050509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610824576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104bc565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000468203611247576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060008181526002602052604081205490819003611294576040517f9a45110f000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b919050565b6000601f19601f830116601f19601f8501166112b79061016061251c565b610eff919061251c565b6060816040516020016112d491906127b6565b6040516020818303038152906040529050919050565b60408051606081018252600080825260208201819052918101919091526113108a611209565b50600089900361134c576040517f0b3e41a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61138b85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec90611405908e908c908c9060040161245c565b602060405180830381865afa158015611422573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611446919061247f565b90508034101561148b576040517f9557ee49000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016104bc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aa2f06ae6040518163ffffffff1660e01b81526004016040805180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611519919061253a565b83602001846040018267ffffffffffffffff1667ffffffffffffffff1681525082815250505060006115d2338d8d866020015187604001518c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611ca792505050565b90506115dd816119bf565b8360000181815250506000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367c769af85856040015188600001518f8f6040518663ffffffff1660e01b81526004016116519493929190612837565b604080518083038185885af115801561166e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611693919061253a565b915091508460200151821480156116c15750846040015167ffffffffffffffff168167ffffffffffffffff16145b6116cd576116cd612857565b50503482810390831461177657600154604080840151865191517fffecec7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263ffecec7e92859261174392909190600401918252602082015260400190565b6000604051808303818588803b15801561175c57600080fd5b505af1158015611770573d6000803e3d6000fd5b50505050505b73ffffffffffffffffffffffffffffffffffffffff8b161561193f5773ffffffffffffffffffffffffffffffffffffffff8b1663e4e065228e6117b98a89611299565b87516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526117fc9392919087908f908f90600401612886565b600060405180830381600087803b15801561181657600080fd5b505af115801561182a573d6000803e3d6000fd5b5050505060008b73ffffffffffffffffffffffffffffffffffffffff166362014bad6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906128be565b600154604085810151885191517f0676b7060000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915273ffffffffffffffffffffffffffffffffffffffff8084166044830152929350911690630676b70690606401600060405180830381600087803b15801561192557600080fd5b505af1158015611939573d6000803e3d6000fd5b50505050505b8160a0015167ffffffffffffffff16826080015185600001517f1b22d6c0b67f6f17a9004833bfb5afbaea4602457bd57e1d128cb997fb30161b85604001518660200151876060015189888a60c001518b60e001516040516119a797969594939291906128db565b60405180910390a45050509998505050505050505050565b6000816040516020016119d291906127b6565b604051602081830303815290604052805190602001209050919050565b6000600282511015611a2f57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016104bc919061221b565b506020015160f01c90565b6060600282511015611a7a57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016104bc919061221b565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff811115611ab757611ab7611fcd565b6040519080825280601f01601f191660200182016040528015611ae1576020820181803683370190505b50915060008160208401836022870160045afa905080611b2d576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60408051808201909152600080825260208201526000611b53836119ef565b9050600161ffff82161015610ee3576040517faac8bd2300000000000000000000000000000000000000000000000000000000815261ffff821660048201526024016104bc565b6000805b8651811015611c9d5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367b1f42e898481518110611bf757611bf761291e565b60200260200101518989896040518563ffffffff1660e01b8152600401611c21949392919061294d565b602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c62919061247f565b90508015801590611c7b575042611c79858361251c565b105b15611c8c57611c89836129f8565b92505b50611c96816129f8565b9050611b9e565b5095945050505050565b611cff6040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b604051806101000160405280468152602001611d2e8a73ffffffffffffffffffffffffffffffffffffffff1690565b81526020018881526020018781526020018681526020018567ffffffffffffffff168152602001848152602001838152509050979650505050505050565b600060208284031215611d7e57600080fd5b5035919050565b60008083601f840112611d9757600080fd5b50813567ffffffffffffffff811115611daf57600080fd5b602083019150836020828501011115611dc757600080fd5b9250929050565b60008083601f840112611de057600080fd5b50813567ffffffffffffffff811115611df857600080fd5b6020830191508360208260051b8501011115611dc757600080fd5b60008060008060408587031215611e2957600080fd5b843567ffffffffffffffff80821115611e4157600080fd5b611e4d88838901611d85565b90965094506020870135915080821115611e6657600080fd5b50611e7387828801611dce565b95989497509550505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d3757600080fd5b600060208284031215611eb357600080fd5b8135610eff81611e7f565b600080600080600060608688031215611ed657600080fd5b85359450602086013567ffffffffffffffff80821115611ef557600080fd5b611f0189838a01611d85565b90965094506040880135915080821115611f1a57600080fd5b50611f2788828901611dce565b969995985093965092949392505050565b600080600080600080600060a0888a031215611f5357600080fd5b873596506020880135611f6581611e7f565b9550604088013567ffffffffffffffff80821115611f8257600080fd5b611f8e8b838c01611dce565b909750955060608a0135915080821115611fa757600080fd5b50611fb48a828b01611d85565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff8111828210171561202057612020611fcd565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561204f5761204f611fcd565b604052919050565b67ffffffffffffffff81168114610d3757600080fd5b803561129481612057565b600067ffffffffffffffff82111561209257612092611fcd565b50601f01601f191660200190565b600082601f8301126120b157600080fd5b81356120c46120bf82612078565b612026565b8181528460208386010111156120d957600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561210857600080fd5b813567ffffffffffffffff8082111561212057600080fd5b90830190610100828603121561213557600080fd5b61213d611ffc565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015261217560a0840161206d565b60a082015260c08301358281111561218c57600080fd5b612198878286016120a0565b60c08301525060e0830135828111156121b057600080fd5b6121bc878286016120a0565b60e08301525095945050505050565b60005b838110156121e65781810151838201526020016121ce565b50506000910152565b600081518084526122078160208601602086016121cb565b601f01601f19169290920160200192915050565b602081526000610eff60208301846121ef565b600080600080600080600080600060c08a8c03121561224c57600080fd5b8935985060208a013561225e81611e7f565b975060408a013561226e81611e7f565b965060608a013567ffffffffffffffff8082111561228b57600080fd5b6122978d838e01611dce565b909850965060808c01359150808211156122b057600080fd5b6122bc8d838e01611d85565b909650945060a08c01359150808211156122d557600080fd5b506122e28c828d01611d85565b915080935050809150509295985092959850929598565b600080600080600080600080600060c08a8c03121561231757600080fd5b8935985060208a0135975060408a013561226e81611e7f565b60006020828403121561234257600080fd5b813567ffffffffffffffff81111561235957600080fd5b612365848285016120a0565b949350505050565b6000806040838503121561238057600080fd5b50508035926020909101359150565b600080602083850312156123a257600080fd5b823567ffffffffffffffff8111156123b957600080fd5b6123c585828601611d85565b90969095509350505050565b85815284602082015283604082015267ffffffffffffffff8316606082015260a0608082015260006109fd60a08301846121ef565b8183526000602080850194508260005b8581101561245157813561242981611e7f565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101612416565b509495945050505050565b838152604060208201526000612476604083018486612406565b95945050505050565b60006020828403121561249157600080fd5b5051919050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b8481528360208201526060604082015260006124e3606083018486612498565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610a1357610a136124ed565b805161129481612057565b6000806040838503121561254d57600080fd5b82519150602083015161255f81612057565b809150509250929050565b600082601f83011261257b57600080fd5b81516125896120bf82612078565b81815284602083860101111561259e57600080fd5b6123658260208301602087016121cb565b6000602082840312156125c157600080fd5b815167ffffffffffffffff808211156125d957600080fd5b9083019061010082860312156125ee57600080fd5b6125f6611ffc565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015261262e60a0840161252f565b60a082015260c08301518281111561264557600080fd5b6126518782860161256a565b60c08301525060e08301518281111561266957600080fd5b6121bc8782860161256a565b60006040828403121561268757600080fd5b6040516040810181811067ffffffffffffffff821117156126aa576126aa611fcd565b604052825181526020928301519281019290925250919050565b6000604082840312156126d657600080fd5b610eff8383612675565b600080604083850312156126f357600080fd5b825167ffffffffffffffff8082111561270b57600080fd5b6127178683870161256a565b935060209150818501518181111561272e57600080fd5b8501601f8101871361273f57600080fd5b80518281111561275157612751611fcd565b8060051b9250612762848401612026565b818152928201840192848101908985111561277c57600080fd5b928501925b848410156127a6578351925061279683611e7f565b8282529285019290850190612781565b8096505050505050509250929050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015267ffffffffffffffff60a08301511660c0820152600060c08301516101008060e085015261281b6101208501836121ef565b915060e0850151601f1985840301828601526124e383826121ef565b8481528360208201526060604082015260006124e3606083018486612406565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b86815285602082015284604082015283606082015260a0608082015260006128b260a083018486612498565b98975050505050505050565b6000602082840312156128d057600080fd5b8151610eff81611e7f565b87815286602082015285604082015284606082015283608082015260e060a0820152600061290c60e08301856121ef565b82810360c0840152610c5a81856121ef565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff85168152835160208201526020840151604082015267ffffffffffffffff604085015116606082015260608401516080820152608084015160a082015260e060c08201528160e082015260006101007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8411156129de57600080fd5b8360051b8086838601379290920190910195945050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612a2957612a296124ed565b506001019056fea2646970667358221220efec5b8efc94ceff35688c624c61b3f55ac46dfae8b34b0d0bbd373b1de4af8664736f6c63430008140033", } // InterchainClientV1ABI is the input ABI used to generate the binding from. @@ -2677,7 +2677,7 @@ func (_InterchainClientV1 *InterchainClientV1CallerSession) INTERCHAINDB() (comm // DecodeOptions is a free data retrieval call binding the contract method 0xd5e788a0. // -// Solidity: function decodeOptions(bytes encodedOptions) pure returns((uint256,uint256)) +// Solidity: function decodeOptions(bytes encodedOptions) view returns((uint256,uint256)) func (_InterchainClientV1 *InterchainClientV1Caller) DecodeOptions(opts *bind.CallOpts, encodedOptions []byte) (OptionsV1, error) { var out []interface{} err := _InterchainClientV1.contract.Call(opts, &out, "decodeOptions", encodedOptions) @@ -2694,14 +2694,14 @@ func (_InterchainClientV1 *InterchainClientV1Caller) DecodeOptions(opts *bind.Ca // DecodeOptions is a free data retrieval call binding the contract method 0xd5e788a0. // -// Solidity: function decodeOptions(bytes encodedOptions) pure returns((uint256,uint256)) +// Solidity: function decodeOptions(bytes encodedOptions) view returns((uint256,uint256)) func (_InterchainClientV1 *InterchainClientV1Session) DecodeOptions(encodedOptions []byte) (OptionsV1, error) { return _InterchainClientV1.Contract.DecodeOptions(&_InterchainClientV1.CallOpts, encodedOptions) } // DecodeOptions is a free data retrieval call binding the contract method 0xd5e788a0. // -// Solidity: function decodeOptions(bytes encodedOptions) pure returns((uint256,uint256)) +// Solidity: function decodeOptions(bytes encodedOptions) view returns((uint256,uint256)) func (_InterchainClientV1 *InterchainClientV1CallerSession) DecodeOptions(encodedOptions []byte) (OptionsV1, error) { return _InterchainClientV1.Contract.DecodeOptions(&_InterchainClientV1.CallOpts, encodedOptions) } @@ -4992,7 +4992,7 @@ func (_InterchainClientV1Events *InterchainClientV1EventsFilterer) ParseLinkedCl // InterchainEntryLibMetaData contains all meta data concerning the InterchainEntryLib contract. var InterchainEntryLibMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fa75986447d941d0d0d82ad406b35fa5eff33cb456ed04814bfba416f17295c664736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203917cb63c088797953ca5a9e628901ff18f928c4dd98d65e720730f2060d7fc464736f6c63430008140033", } // InterchainEntryLibABI is the input ABI used to generate the binding from. @@ -5165,7 +5165,7 @@ func (_InterchainEntryLib *InterchainEntryLibTransactorRaw) Transact(opts *bind. // InterchainTransactionLibMetaData contains all meta data concerning the InterchainTransactionLib contract. var InterchainTransactionLibMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122027fd9eaf7fbfbf97c5d523cd33263b7a545d831c13c1bfcb6027b3c292bb264464736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212206dfb957f8af4432556f6a35e558409e46ffcbd678d84d534793ce11656a2b2c064736f6c63430008140033", } // InterchainTransactionLibABI is the input ABI used to generate the binding from. @@ -5338,7 +5338,7 @@ func (_InterchainTransactionLib *InterchainTransactionLibTransactorRaw) Transact // MathLibMetaData contains all meta data concerning the MathLib contract. var MathLibMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207406f0a7a44da8114195fc16d740573c3f89e6362549fba952d0054ad35b9e3b64736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bf4e55b642cf3dc909dd2e784ef75ee441b3575adfcf9ed35769e404aa89765c64736f6c63430008140033", } // MathLibABI is the input ABI used to generate the binding from. @@ -5510,8 +5510,8 @@ func (_MathLib *MathLibTransactorRaw) Transact(opts *bind.TransactOpts, method s // OptionsLibMetaData contains all meta data concerning the OptionsLib contract. var OptionsLibMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220606469f7a1c621594699c1cb221f4c081709b7c7fd4e931cf5c119c428f1d37664736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220356a3cd7f7b16179f69917a934f1eeea5c11dc47e821f09c18ed01cee2e1e7f564736f6c63430008140033", } // OptionsLibABI is the input ABI used to generate the binding from. @@ -6070,7 +6070,7 @@ func (_Ownable *OwnableFilterer) ParseOwnershipTransferred(log types.Log) (*Owna // TypeCastsMetaData contains all meta data concerning the TypeCasts contract. var TypeCastsMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220282b529922d3a9d3f383e64bca7954adc896448545468d8ce7cc2b9aefc9749064736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220475f9dbd1c5667f87fedc7625fb34e1b9331dd3d56514626f4d3d0b84bdc7c2c64736f6c63430008140033", } // TypeCastsABI is the input ABI used to generate the binding from. @@ -6239,3 +6239,176 @@ func (_TypeCasts *TypeCastsTransactorRaw) Transfer(opts *bind.TransactOpts) (*ty func (_TypeCasts *TypeCastsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { return _TypeCasts.Contract.contract.Transact(opts, method, params...) } + +// VersionedPayloadLibMetaData contains all meta data concerning the VersionedPayloadLib contract. +var VersionedPayloadLibMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122029ddcad98141cdc279da3d603abe13774f75baf3aa583bc9d87d0a906dcc25c864736f6c63430008140033", +} + +// VersionedPayloadLibABI is the input ABI used to generate the binding from. +// Deprecated: Use VersionedPayloadLibMetaData.ABI instead. +var VersionedPayloadLibABI = VersionedPayloadLibMetaData.ABI + +// VersionedPayloadLibBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use VersionedPayloadLibMetaData.Bin instead. +var VersionedPayloadLibBin = VersionedPayloadLibMetaData.Bin + +// DeployVersionedPayloadLib deploys a new Ethereum contract, binding an instance of VersionedPayloadLib to it. +func DeployVersionedPayloadLib(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *VersionedPayloadLib, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(VersionedPayloadLibBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// VersionedPayloadLib is an auto generated Go binding around an Ethereum contract. +type VersionedPayloadLib struct { + VersionedPayloadLibCaller // Read-only binding to the contract + VersionedPayloadLibTransactor // Write-only binding to the contract + VersionedPayloadLibFilterer // Log filterer for contract events +} + +// VersionedPayloadLibCaller is an auto generated read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibTransactor is an auto generated write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type VersionedPayloadLibFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type VersionedPayloadLibSession struct { + Contract *VersionedPayloadLib // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type VersionedPayloadLibCallerSession struct { + Contract *VersionedPayloadLibCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// VersionedPayloadLibTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type VersionedPayloadLibTransactorSession struct { + Contract *VersionedPayloadLibTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibRaw is an auto generated low-level Go binding around an Ethereum contract. +type VersionedPayloadLibRaw struct { + Contract *VersionedPayloadLib // Generic contract binding to access the raw methods on +} + +// VersionedPayloadLibCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCallerRaw struct { + Contract *VersionedPayloadLibCaller // Generic read-only contract binding to access the raw methods on +} + +// VersionedPayloadLibTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactorRaw struct { + Contract *VersionedPayloadLibTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewVersionedPayloadLib creates a new instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLib(address common.Address, backend bind.ContractBackend) (*VersionedPayloadLib, error) { + contract, err := bindVersionedPayloadLib(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// NewVersionedPayloadLibCaller creates a new read-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibCaller(address common.Address, caller bind.ContractCaller) (*VersionedPayloadLibCaller, error) { + contract, err := bindVersionedPayloadLib(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibCaller{contract: contract}, nil +} + +// NewVersionedPayloadLibTransactor creates a new write-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibTransactor(address common.Address, transactor bind.ContractTransactor) (*VersionedPayloadLibTransactor, error) { + contract, err := bindVersionedPayloadLib(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibTransactor{contract: contract}, nil +} + +// NewVersionedPayloadLibFilterer creates a new log filterer instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibFilterer(address common.Address, filterer bind.ContractFilterer) (*VersionedPayloadLibFilterer, error) { + contract, err := bindVersionedPayloadLib(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &VersionedPayloadLibFilterer{contract: contract}, nil +} + +// bindVersionedPayloadLib binds a generic wrapper to an already deployed contract. +func bindVersionedPayloadLib(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.VersionedPayloadLibCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transact(opts, method, params...) +} diff --git a/sin-executor/contracts/interchainclient/interchainclient.contractinfo.json b/sin-executor/contracts/interchainclient/interchainclient.contractinfo.json index 140d5cec81..a910e74679 100644 --- a/sin-executor/contracts/interchainclient/interchainclient.contractinfo.json +++ b/sin-executor/contracts/interchainclient/interchainclient.contractinfo.json @@ -1 +1 @@ -{"solidity/InterchainClientV1.sol:AppConfigLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220783dec0d3097ec4bb618b65c167149ccd1cb9539620af566d8d5b2c20a341ebd64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220783dec0d3097ec4bb618b65c167149ccd1cb9539620af566d8d5b2c20a341ebd64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"8319:2072:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;8319:2072:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"8319:2072:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"AppConfigLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"AppConfigLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:Context":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"Context\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:IExecutionFees":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address","name":"executor","type":"address"}],"name":"ExecutionFees__AlreadyRecorded","type":"error"},{"inputs":[],"name":"ExecutionFees__ZeroAddress","type":"error"},{"inputs":[],"name":"ExecutionFees__ZeroAmount","type":"error"},{"inputs":[{"internalType":"address","name":"executor","type":"address"}],"name":"accumulatedRewards","outputs":[{"internalType":"uint256","name":"accumulated","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"addExecutionFee","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"executor","type":"address"}],"name":"claimExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"executionFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address","name":"executor","type":"address"}],"name":"recordExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"recordedExecutor","outputs":[{"internalType":"address","name":"executor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"executor","type":"address"}],"name":"unclaimedRewards","outputs":[{"internalType":"uint256","name":"unclaimed","type":"uint256"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"accumulatedRewards(address)":{"notice":"Get the accumulated rewards for an executor."},"addExecutionFee(uint256,bytes32)":{"notice":"Add the execution fee for a transaction. The attached value will be added to the rewards for the executor completing the transaction. Note: this could be used to store the execution fee for a new transaction, or to add more funds to the execution fee of an existing transaction. Therefore this function is payable, and does not implement any caller restrictions."},"claimExecutionFees(address)":{"notice":"Allows the executor to claim their unclaimed rewards."},"executionFee(uint256,bytes32)":{"notice":"Get the total execution fee for a transaction."},"recordExecutor(uint256,bytes32,address)":{"notice":"Record the executor (who completed the transaction) for a transaction, and update the accumulated rewards for the executor."},"recordedExecutor(uint256,bytes32)":{"notice":"Get the address of the recorded executor for a transaction."},"unclaimedRewards(address)":{"notice":"Get the unclaimed rewards for an executor."}},"version":1},"developerDoc":{"kind":"dev","methods":{"accumulatedRewards(address)":{"params":{"executor":"The address of the executor to get the rewards for."}},"addExecutionFee(uint256,bytes32)":{"details":"Will revert if the executor is already recorded for the transaction.","params":{"dstChainId":"The chain id of the destination chain.","transactionId":"The id of the transaction to add the execution fee to."}},"claimExecutionFees(address)":{"details":"Will revert if the executor has no unclaimed rewards."},"executionFee(uint256,bytes32)":{"params":{"dstChainId":"The chain id of the destination chain.","transactionId":"The id of the transaction to get the execution fee for."}},"recordExecutor(uint256,bytes32,address)":{"details":"Could only be called by the Recorder.","params":{"dstChainId":"The chain id of the destination chain.","executor":"The address of the executor who completed the transaction.","transactionId":"The id of the transaction to record the executor for."}},"recordedExecutor(uint256,bytes32)":{"details":"Will return address(0) if the executor is not recorded.","params":{"dstChainId":"The chain id of the destination chain.","transactionId":"The id of the transaction to get the recorded executor for."}},"unclaimedRewards(address)":{"params":{"executor":"The address of the executor to get the rewards for."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionFees__AlreadyRecorded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ExecutionFees__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ExecutionFees__ZeroAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"accumulatedRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"accumulated\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"addExecutionFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"claimExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"executionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"recordExecutor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"recordedExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"unclaimedRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"unclaimed\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"accumulatedRewards(address)\":{\"params\":{\"executor\":\"The address of the executor to get the rewards for.\"}},\"addExecutionFee(uint256,bytes32)\":{\"details\":\"Will revert if the executor is already recorded for the transaction.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"transactionId\":\"The id of the transaction to add the execution fee to.\"}},\"claimExecutionFees(address)\":{\"details\":\"Will revert if the executor has no unclaimed rewards.\"},\"executionFee(uint256,bytes32)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"transactionId\":\"The id of the transaction to get the execution fee for.\"}},\"recordExecutor(uint256,bytes32,address)\":{\"details\":\"Could only be called by the Recorder.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executor\":\"The address of the executor who completed the transaction.\",\"transactionId\":\"The id of the transaction to record the executor for.\"}},\"recordedExecutor(uint256,bytes32)\":{\"details\":\"Will return address(0) if the executor is not recorded.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"transactionId\":\"The id of the transaction to get the recorded executor for.\"}},\"unclaimedRewards(address)\":{\"params\":{\"executor\":\"The address of the executor to get the rewards for.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"accumulatedRewards(address)\":{\"notice\":\"Get the accumulated rewards for an executor.\"},\"addExecutionFee(uint256,bytes32)\":{\"notice\":\"Add the execution fee for a transaction. The attached value will be added to the rewards for the executor completing the transaction. Note: this could be used to store the execution fee for a new transaction, or to add more funds to the execution fee of an existing transaction. Therefore this function is payable, and does not implement any caller restrictions.\"},\"claimExecutionFees(address)\":{\"notice\":\"Allows the executor to claim their unclaimed rewards.\"},\"executionFee(uint256,bytes32)\":{\"notice\":\"Get the total execution fee for a transaction.\"},\"recordExecutor(uint256,bytes32,address)\":{\"notice\":\"Record the executor (who completed the transaction) for a transaction, and update the accumulated rewards for the executor.\"},\"recordedExecutor(uint256,bytes32)\":{\"notice\":\"Get the address of the recorded executor for a transaction.\"},\"unclaimedRewards(address)\":{\"notice\":\"Get the unclaimed rewards for an executor.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IExecutionFees\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"accumulatedRewards(address)":"73f273fc","addExecutionFee(uint256,bytes32)":"ffecec7e","claimExecutionFees(address)":"4e497dac","executionFee(uint256,bytes32)":"936fd4db","recordExecutor(uint256,bytes32,address)":"0676b706","recordedExecutor(uint256,bytes32)":"d01e09a6","unclaimedRewards(address)":"949813b8"}},"solidity/InterchainClientV1.sol:IExecutionService":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IExecutionService\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"executorEOA()":"62014bad","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522"}},"solidity/InterchainClientV1.sol:IInterchainApp":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."}},"notice":"Minimal interface for the Interchain App to work with the Interchain Client.","version":1},"developerDoc":{"kind":"dev","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"}},\"notice\":\"Minimal interface for the Interchain App to work with the Interchain Client.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IInterchainApp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getReceivingConfig()":"287bc057"}},"solidity/InterchainClientV1.sol:IInterchainClientV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__FeeAmountTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__IncorrectDstChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__IncorrectMsgValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NoLinkedClient","type":"error"},{"inputs":[{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"InterchainClientV1__NotEVMClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__NotEnoughResponses","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NotRemoteChainId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxAlreadyExecuted","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxNotExecuted","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroReceiver","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroRequiredResponses","type":"error"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"}],"name":"getExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getExecutorById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"uint256","name":"messageLen","type":"uint256"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClient","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClientEVM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"interchainExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSend","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSendEVM","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"isExecutable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"executionFees_","type":"address"}],"name":"setExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"setLinkedClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"writeExecutionProof","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"getExecutor(bytes)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getExecutorById(bytes32)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getInterchainFee(uint256,address,address[],bytes,uint256)":{"notice":"Returns the fee for sending an Interchain message."},"getLinkedClient(uint256)":{"notice":"Returns the address of the linked client (as bytes32) for a specific chain ID."},"getLinkedClientEVM(uint256)":{"notice":"Returns the EVM address of the linked client for a specific chain ID."},"interchainExecute(uint256,bytes,bytes32[])":{"notice":"Executes a transaction that has been sent via the Interchain."},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"notice":"Sends a message to another chain via the Interchain Communication Protocol."},"isExecutable(bytes,bytes32[])":{"notice":"Checks if a transaction is executable."},"setExecutionFees(address)":{"notice":"Sets the address of the ExecutionFees contract."},"setLinkedClient(uint256,bytes32)":{"notice":"Sets the linked client for a specific chain ID."},"writeExecutionProof(bytes32)":{"notice":"Writes the proof of execution for a transaction into the InterchainDB."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getInterchainFee(uint256,address,address[],bytes,uint256)":{"params":{"dstChainId":"The chain ID of the destination chain.","messageLen":"The length of the message being sent.","options":"Execution options for the message sent, currently gas limit + native gas drop.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."}},"getLinkedClient(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID."},"getLinkedClientEVM(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client."},"interchainExecute(uint256,bytes,bytes32[])":{"details":"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.","params":{"gasLimit":"The gas limit to use for the execution.","proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The transaction data."}},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"details":"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.","params":{"dstChainId":"The chain ID of the destination chain.","message":"The message being sent.","options":"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.","receiver":"The address of the receiver on the destination chain.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."},"returns":{"desc":"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch."}},"isExecutable(bytes,bytes32[])":{"details":"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules","params":{"proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The InterchainTransaction struct to be checked."},"returns":{"_0":"bool Returns true if the transaction is executable, false otherwise."}},"setExecutionFees(address)":{"details":"Only callable by the contract owner or an authorized account.","params":{"executionFees_":"The address of the ExecutionFees contract."}},"setLinkedClient(uint256,bytes32)":{"details":"Stores the address of the linked client in a mapping with the chain ID as the key.","params":{"chainId":"The chain ID for which the client is being set.","client":"The address of the client being linked."}},"writeExecutionProof(bytes32)":{"details":"Will revert if the transaction has not been executed.","params":{"transactionId":"The ID of the transaction to write the proof for."},"returns":{"dbNonce":" The database nonce of the batch containing the written proof for transaction.","entryIndex":" The index of the written proof for transaction within the batch."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"messageLen\":\"The length of the message being sent.\",\"options\":\"Execution options for the message sent, currently gas limit + native gas drop.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"}},\"getLinkedClient(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"details\":\"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.\",\"params\":{\"gasLimit\":\"The gas limit to use for the execution.\",\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The transaction data.\"}},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"details\":\"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.\",\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"message\":\"The message being sent.\",\"options\":\"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\",\"receiver\":\"The address of the receiver on the destination chain.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"},\"returns\":{\"desc\":\"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch.\"}},\"isExecutable(bytes,bytes32[])\":{\"details\":\"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules\",\"params\":{\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The InterchainTransaction struct to be checked.\"},\"returns\":{\"_0\":\"bool Returns true if the transaction is executable, false otherwise.\"}},\"setExecutionFees(address)\":{\"details\":\"Only callable by the contract owner or an authorized account.\",\"params\":{\"executionFees_\":\"The address of the ExecutionFees contract.\"}},\"setLinkedClient(uint256,bytes32)\":{\"details\":\"Stores the address of the linked client in a mapping with the chain ID as the key.\",\"params\":{\"chainId\":\"The chain ID for which the client is being set.\",\"client\":\"The address of the client being linked.\"}},\"writeExecutionProof(bytes32)\":{\"details\":\"Will revert if the transaction has not been executed.\",\"params\":{\"transactionId\":\"The ID of the transaction to write the proof for.\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written proof for transaction.\",\"entryIndex\":\" The index of the written proof for transaction within the batch.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getExecutor(bytes)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getExecutorById(bytes32)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"notice\":\"Returns the fee for sending an Interchain message.\"},\"getLinkedClient(uint256)\":{\"notice\":\"Returns the address of the linked client (as bytes32) for a specific chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"notice\":\"Returns the EVM address of the linked client for a specific chain ID.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"notice\":\"Executes a transaction that has been sent via the Interchain.\"},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"notice\":\"Sends a message to another chain via the Interchain Communication Protocol.\"},\"isExecutable(bytes,bytes32[])\":{\"notice\":\"Checks if a transaction is executable.\"},\"setExecutionFees(address)\":{\"notice\":\"Sets the address of the ExecutionFees contract.\"},\"setLinkedClient(uint256,bytes32)\":{\"notice\":\"Sets the linked client for a specific chain ID.\"},\"writeExecutionProof(bytes32)\":{\"notice\":\"Writes the proof of execution for a transaction into the InterchainDB.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IInterchainClientV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"getExecutor(bytes)":"f92a79ff","getExecutorById(bytes32)":"f1a61fac","getInterchainFee(uint256,address,address[],bytes,uint256)":"7a1277db","getLinkedClient(uint256)":"aa102ec4","getLinkedClientEVM(uint256)":"02172a35","interchainExecute(uint256,bytes,bytes32[])":"53b67d74","interchainSend(uint256,bytes32,address,address[],bytes,bytes)":"98939d28","interchainSendEVM(uint256,address,address,address[],bytes,bytes)":"827f940d","isExecutable(bytes,bytes32[])":"1450c281","setExecutionFees(address)":"3dc68b87","setLinkedClient(uint256,bytes32)":"f34234c8","writeExecutionProof(bytes32)":"90e81077"}},"solidity/InterchainClientV1.sol:IInterchainDB":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"InterchainDB__BatchDoesNotExist","type":"error"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"InterchainDB__BatchNotFinalized","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"},{"internalType":"bytes32","name":"existingBatchRoot","type":"bytes32"},{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"bytes32","name":"batchRoot","type":"bytes32"}],"internalType":"struct InterchainBatch","name":"newBatch","type":"tuple"}],"name":"InterchainDB__ConflictingBatches","type":"error"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"uint64","name":"batchSize","type":"uint64"}],"name":"InterchainDB__EntryIndexOutOfRange","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualFee","type":"uint256"},{"internalType":"uint256","name":"expectedFee","type":"uint256"}],"name":"InterchainDB__IncorrectFeeAmount","type":"error"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"}],"name":"InterchainDB__InvalidEntryRange","type":"error"},{"inputs":[],"name":"InterchainDB__NoModulesSpecified","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainDB__SameChainId","type":"error"},{"inputs":[{"internalType":"address","name":"dstModule","type":"address"},{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes32","name":"srcWriter","type":"bytes32"},{"internalType":"bytes32","name":"dataHash","type":"bytes32"}],"internalType":"struct InterchainEntry","name":"entry","type":"tuple"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"checkVerification","outputs":[{"internalType":"uint256","name":"moduleVerifiedAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"getBatch","outputs":[{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"bytes32","name":"batchRoot","type":"bytes32"}],"internalType":"struct InterchainBatch","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"getBatchLeafs","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"}],"name":"getBatchLeafsPaginated","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"getBatchSize","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDBNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"name":"getEntryProof","outputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"name":"getEntryValue","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address[]","name":"srcModules","type":"address[]"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextEntryIndex","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"address[]","name":"srcModules","type":"address[]"}],"name":"requestBatchVerification","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"bytes32","name":"batchRoot","type":"bytes32"}],"internalType":"struct InterchainBatch","name":"batch","type":"tuple"}],"name":"verifyRemoteBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataHash","type":"bytes32"}],"name":"writeEntry","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"address[]","name":"srcModules","type":"address[]"}],"name":"writeEntryWithVerification","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"payable","type":"function"}],"userDoc":{"kind":"user","methods":{"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])":{"notice":"Read the data written on specific source chain by a specific writer, and verify it on the destination chain using the provided Interchain Module. Note: returned zero value indicates that the module has not verified the entry."},"getBatch(uint256)":{"notice":"Get the finalized Interchain Batch with the given nonce."},"getBatchLeafs(uint256)":{"notice":"Returns the list of leafs of the finalized batch with the given nonce. Note: the leafs are ordered by the index of the written entry in the current batch, and the leafs value match the value of the written entry (srcWriter + dataHash hashed together)."},"getBatchLeafsPaginated(uint256,uint64,uint64)":{"notice":"Returns the list of leafs of the finalized batch with the given nonce, paginated by the given start and end indexes. The end index is exclusive. Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs` would result in a gas limit exceeded error."},"getBatchSize(uint256)":{"notice":"Returns the size of the finalized batch with the given nonce."},"getDBNonce()":{"notice":"Get the nonce of the database, which is incremented every time a new batch is finalized. This is the nonce of the current non-finalized batch."},"getEntryProof(uint256,uint64)":{"notice":"Get the Merkle proof of inclusion for the entry with the given index in the finalized batch with the given nonce."},"getEntryValue(uint256,uint64)":{"notice":"Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index. Entry value is calculated as the hash of the writer address and the written data hash. Note: the batch does not have to be finalized to fetch the entry value."},"getInterchainFee(uint256,address[])":{"notice":"Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain using the provided Interchain Modules."},"getNextEntryIndex()":{"notice":"Get the index of the next entry to be written to the database."},"requestBatchVerification(uint256,uint256,address[])":{"notice":"Request the given Interchain Modules to verify an existing batch. If the batch is not finalized, the module will verify it after finalization. For the finalized batch the batch root is already available, and the module can verify it immediately. Note: every module has a separate fee paid in the native gas token of the source chain, and `msg.value` must be equal to the sum of all fees. Note: this method is permissionless, and anyone can request verification for any batch."},"verifyRemoteBatch((uint256,uint256,bytes32))":{"notice":"Allows the Interchain Module to verify the batch coming from the remote chain."},"writeEntry(bytes32)":{"notice":"Write data to the Interchain DataBase as a new entry in the current batch. Note: there are no guarantees that this entry will be available for reading on any of the remote chains. Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain."},"writeEntryWithVerification(uint256,bytes32,address[])":{"notice":"Write data to the Interchain DataBase as a new entry in the current batch. Then request the Interchain Modules to verify the batch containing the written entry on the destination chain. See `writeEntry` and `requestBatchVerification` for more details."}},"version":1},"developerDoc":{"kind":"dev","methods":{"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])":{"params":{"dstModule":"The destination chain addresses of the Interchain Modules to use for verification","entry":"The Interchain Entry to read"},"returns":{"moduleVerifiedAt":" The block timestamp at which the entry was verified by the module, or ZERO if the module has not verified the entry."}},"getBatch(uint256)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized.","params":{"dbNonce":"The database nonce of the finalized batch"}},"getBatchLeafs(uint256)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized.","params":{"dbNonce":"The database nonce of the finalized batch"}},"getBatchLeafsPaginated(uint256,uint64,uint64)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the provided range is invalid.","params":{"dbNonce":"The database nonce of the finalized batch","end":"The end index of the paginated leafs, exclusive","start":"The start index of the paginated leafs, inclusive"}},"getBatchSize(uint256)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized.","params":{"dbNonce":"The database nonce of the finalized batch"}},"getEntryProof(uint256,uint64)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the entry with the given index does not exist within the batch.","params":{"dbNonce":"The database nonce of the finalized batch","entryIndex":"The index of the written entry within the batch"},"returns":{"proof":" The Merkle proof of inclusion for the entry"}},"getEntryValue(uint256,uint64)":{"details":"Will revert if the batch with the given nonce does not exist, or the entry with the given index does not exist within the batch.","params":{"dbNonce":"The database nonce of the existing batch","entryIndex":"The index of the written entry within the batch"}},"getInterchainFee(uint256,address[])":{"details":"Will revert if the empty array of modules is provided.","params":{"dstChainId":"The chain id of the destination chain","srcModules":"The source chain addresses of the Interchain Modules to use for verification"}},"getNextEntryIndex()":{"returns":{"dbNonce":" The database nonce of the batch including the next entry","entryIndex":" The index of the next entry within that batch"}},"requestBatchVerification(uint256,uint256,address[])":{"details":"Will revert if the batch with the given nonce does not exist.","params":{"dbNonce":"The database nonce of the existing batch","dstChainId":"The chain id of the destination chain","srcModules":"The source chain addresses of the Interchain Modules to use for verification"}},"verifyRemoteBatch((uint256,uint256,bytes32))":{"params":{"batch":"The Interchain Batch to confirm"}},"writeEntry(bytes32)":{"params":{"dataHash":"The hash of the data to be written to the Interchain DataBase as a new entry"},"returns":{"dbNonce":" The database nonce of the batch containing the written entry","entryIndex":" The index of the written entry within the batch"}},"writeEntryWithVerification(uint256,bytes32,address[])":{"details":"Will revert if the empty array of modules is provided.","params":{"dataHash":"The hash of the data to be written to the Interchain DataBase as a new entry","dstChainId":"The chain id of the destination chain","srcModules":"The source chain addresses of the Interchain Modules to use for verification"},"returns":{"dbNonce":" The database nonce of the batch containing the written entry","entryIndex":" The index of the written entry within the batch"}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__BatchDoesNotExist\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__BatchNotFinalized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"existingBatchRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"batchRoot\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainBatch\",\"name\":\"newBatch\",\"type\":\"tuple\"}],\"name\":\"InterchainDB__ConflictingBatches\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"batchSize\",\"type\":\"uint64\"}],\"name\":\"InterchainDB__EntryIndexOutOfRange\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actualFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedFee\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__IncorrectFeeAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"start\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"end\",\"type\":\"uint64\"}],\"name\":\"InterchainDB__InvalidEntryRange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainDB__NoModulesSpecified\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"dstModule\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"srcWriter\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataHash\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainEntry\",\"name\":\"entry\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"checkVerification\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"moduleVerifiedAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"getBatch\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"batchRoot\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainBatch\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"getBatchLeafs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"start\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"end\",\"type\":\"uint64\"}],\"name\":\"getBatchLeafsPaginated\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"getBatchSize\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDBNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"name\":\"getEntryProof\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"name\":\"getEntryValue\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNextEntryIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"}],\"name\":\"requestBatchVerification\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"batchRoot\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainBatch\",\"name\":\"batch\",\"type\":\"tuple\"}],\"name\":\"verifyRemoteBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"dataHash\",\"type\":\"bytes32\"}],\"name\":\"writeEntry\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"dataHash\",\"type\":\"bytes32\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"}],\"name\":\"writeEntryWithVerification\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])\":{\"params\":{\"dstModule\":\"The destination chain addresses of the Interchain Modules to use for verification\",\"entry\":\"The Interchain Entry to read\"},\"returns\":{\"moduleVerifiedAt\":\" The block timestamp at which the entry was verified by the module, or ZERO if the module has not verified the entry.\"}},\"getBatch(uint256)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\"}},\"getBatchLeafs(uint256)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\"}},\"getBatchLeafsPaginated(uint256,uint64,uint64)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the provided range is invalid.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\",\"end\":\"The end index of the paginated leafs, exclusive\",\"start\":\"The start index of the paginated leafs, inclusive\"}},\"getBatchSize(uint256)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\"}},\"getEntryProof(uint256,uint64)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the entry with the given index does not exist within the batch.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\",\"entryIndex\":\"The index of the written entry within the batch\"},\"returns\":{\"proof\":\" The Merkle proof of inclusion for the entry\"}},\"getEntryValue(uint256,uint64)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or the entry with the given index does not exist within the batch.\",\"params\":{\"dbNonce\":\"The database nonce of the existing batch\",\"entryIndex\":\"The index of the written entry within the batch\"}},\"getInterchainFee(uint256,address[])\":{\"details\":\"Will revert if the empty array of modules is provided.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain\",\"srcModules\":\"The source chain addresses of the Interchain Modules to use for verification\"}},\"getNextEntryIndex()\":{\"returns\":{\"dbNonce\":\" The database nonce of the batch including the next entry\",\"entryIndex\":\" The index of the next entry within that batch\"}},\"requestBatchVerification(uint256,uint256,address[])\":{\"details\":\"Will revert if the batch with the given nonce does not exist.\",\"params\":{\"dbNonce\":\"The database nonce of the existing batch\",\"dstChainId\":\"The chain id of the destination chain\",\"srcModules\":\"The source chain addresses of the Interchain Modules to use for verification\"}},\"verifyRemoteBatch((uint256,uint256,bytes32))\":{\"params\":{\"batch\":\"The Interchain Batch to confirm\"}},\"writeEntry(bytes32)\":{\"params\":{\"dataHash\":\"The hash of the data to be written to the Interchain DataBase as a new entry\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written entry\",\"entryIndex\":\" The index of the written entry within the batch\"}},\"writeEntryWithVerification(uint256,bytes32,address[])\":{\"details\":\"Will revert if the empty array of modules is provided.\",\"params\":{\"dataHash\":\"The hash of the data to be written to the Interchain DataBase as a new entry\",\"dstChainId\":\"The chain id of the destination chain\",\"srcModules\":\"The source chain addresses of the Interchain Modules to use for verification\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written entry\",\"entryIndex\":\" The index of the written entry within the batch\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])\":{\"notice\":\"Read the data written on specific source chain by a specific writer, and verify it on the destination chain using the provided Interchain Module. Note: returned zero value indicates that the module has not verified the entry.\"},\"getBatch(uint256)\":{\"notice\":\"Get the finalized Interchain Batch with the given nonce.\"},\"getBatchLeafs(uint256)\":{\"notice\":\"Returns the list of leafs of the finalized batch with the given nonce. Note: the leafs are ordered by the index of the written entry in the current batch, and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\"},\"getBatchLeafsPaginated(uint256,uint64,uint64)\":{\"notice\":\"Returns the list of leafs of the finalized batch with the given nonce, paginated by the given start and end indexes. The end index is exclusive. Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs` would result in a gas limit exceeded error.\"},\"getBatchSize(uint256)\":{\"notice\":\"Returns the size of the finalized batch with the given nonce.\"},\"getDBNonce()\":{\"notice\":\"Get the nonce of the database, which is incremented every time a new batch is finalized. This is the nonce of the current non-finalized batch.\"},\"getEntryProof(uint256,uint64)\":{\"notice\":\"Get the Merkle proof of inclusion for the entry with the given index in the finalized batch with the given nonce.\"},\"getEntryValue(uint256,uint64)\":{\"notice\":\"Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index. Entry value is calculated as the hash of the writer address and the written data hash. Note: the batch does not have to be finalized to fetch the entry value.\"},\"getInterchainFee(uint256,address[])\":{\"notice\":\"Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain using the provided Interchain Modules.\"},\"getNextEntryIndex()\":{\"notice\":\"Get the index of the next entry to be written to the database.\"},\"requestBatchVerification(uint256,uint256,address[])\":{\"notice\":\"Request the given Interchain Modules to verify an existing batch. If the batch is not finalized, the module will verify it after finalization. For the finalized batch the batch root is already available, and the module can verify it immediately. Note: every module has a separate fee paid in the native gas token of the source chain, and `msg.value` must be equal to the sum of all fees. Note: this method is permissionless, and anyone can request verification for any batch.\"},\"verifyRemoteBatch((uint256,uint256,bytes32))\":{\"notice\":\"Allows the Interchain Module to verify the batch coming from the remote chain.\"},\"writeEntry(bytes32)\":{\"notice\":\"Write data to the Interchain DataBase as a new entry in the current batch. Note: there are no guarantees that this entry will be available for reading on any of the remote chains. Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\"},\"writeEntryWithVerification(uint256,bytes32,address[])\":{\"notice\":\"Write data to the Interchain DataBase as a new entry in the current batch. Then request the Interchain Modules to verify the batch containing the written entry on the destination chain. See `writeEntry` and `requestBatchVerification` for more details.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IInterchainDB\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])":"67b1f42e","getBatch(uint256)":"5ac44282","getBatchLeafs(uint256)":"d63020bb","getBatchLeafsPaginated(uint256,uint64,uint64)":"25a1641d","getBatchSize(uint256)":"b955e9b9","getDBNonce()":"f338140e","getEntryProof(uint256,uint64)":"4f84d040","getEntryValue(uint256,uint64)":"afa25005","getInterchainFee(uint256,address[])":"fc7686ec","getNextEntryIndex()":"aa2f06ae","requestBatchVerification(uint256,uint256,address[])":"84b1c8b8","verifyRemoteBatch((uint256,uint256,bytes32))":"05d0728c","writeEntry(bytes32)":"2ad8c706","writeEntryWithVerification(uint256,bytes32,address[])":"67c769af"}},"solidity/InterchainClientV1.sol:InterchainBatchLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a7165588fec5b6b13f17833c19ba7286717f3c1019c9e7ab8acbad3da0a717b364736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a7165588fec5b6b13f17833c19ba7286717f3c1019c9e7ab8acbad3da0a717b364736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"11041:842:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;11041:842:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"11041:842:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainBatchLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:InterchainClientV1":{"code":"0x60a06040523480156200001157600080fd5b5060405162002b0438038062002b048339810160408190526200003491620000f0565b806001600160a01b0381166200006457604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b6200006f8162000083565b50506001600160a01b031660805262000128565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000eb57600080fd5b919050565b600080604083850312156200010457600080fd5b6200010f83620000d3565b91506200011f60208401620000d3565b90509250929050565b6080516129966200016e600039600081816103bd015281816108af01528181610b46015281816113ce0152818161148f015281816115ed0152611a8c01526129966000f3fe6080604052600436106101445760003560e01c80638da5cb5b116100c0578063e4c6124711610074578063f2fde38b11610059578063f2fde38b14610422578063f34234c814610442578063f92a79ff1461046257600080fd5b8063e4c61247146103ab578063f1a61fac146103df57600080fd5b806398939d28116100a557806398939d281461033d578063aa102ec414610350578063d5e788a01461037057600080fd5b80638da5cb5b146102d457806390e81077146102ff57600080fd5b8063715018a6116101175780637a1277db116100fc5780637a1277db1461023a5780637c80a90f14610268578063827f940d1461029557600080fd5b8063715018a6146101f85780637341eaf91461020d57600080fd5b806302172a35146101495780631450c281146101935780633dc68b87146101c357806353b67d74146101e5575b600080fd5b34801561015557600080fd5b50610169610164366004611c4d565b610482565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561019f57600080fd5b506101b36101ae366004611cf4565b61052e565b604051901515815260200161018a565b3480156101cf57600080fd5b506101e36101de366004611d82565b610598565b005b6101e36101f3366004611d9f565b610619565b34801561020457600080fd5b506101e3610812565b34801561021957600080fd5b506001546101699073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024657600080fd5b5061025a610255366004611e19565b610826565b60405190815260200161018a565b34801561027457600080fd5b50610288610283366004611fd7565b610a08565b60405161018a91906120fc565b6102a86102a336600461210f565b610a19565b6040805182518152602080840151908201529181015167ffffffffffffffff169082015260600161018a565b3480156102e057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610169565b34801561030b57600080fd5b5061031f61031a366004611c4d565b610a6d565b6040805192835267ffffffffffffffff90911660208301520161018a565b6102a861034b3660046121da565b610c2c565b34801561035c57600080fd5b5061025a61036b366004611c4d565b610c68565b34801561037c57600080fd5b5061039061038b366004612211565b610cb9565b6040805182518152602092830151928101929092520161018a565b3480156103b757600080fd5b506101697f000000000000000000000000000000000000000000000000000000000000000081565b3480156103eb57600080fd5b506101696103fa366004611c4d565b60009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b34801561042e57600080fd5b506101e361043d366004611d82565b610cd6565b34801561044e57600080fd5b506101e361045d366004612246565b610d3a565b34801561046e57600080fd5b5061016961047d366004612268565b610d91565b60004682036104c5576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b506000818152600260205260409020548073ffffffffffffffffffffffffffffffffffffffff81168114610528576040517f0a55a4eb000000000000000000000000000000000000000000000000000000008152600481018290526024016104bc565b50919050565b60008061057086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905061057f8160c00151610e7d565b5061058b818585610f01565b5060019695505050505050565b6105a061113c565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fec02f15d78cdfc4beeba45f31cfad25089004e5e3d72727168dd96a77d1f2f829060200160405180910390a150565b600061065a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b90506000610669828585610f01565b600081815260036020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317905560c0840151919250906106b190610e7d565b9050806020015134146106ff5760208101516040517f2b36102500000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016104bc565b805188101561070d57805197505b606083015173ffffffffffffffffffffffffffffffffffffffff166368a6984789348660000151876020015188608001518960a001518a60e001516040518863ffffffff1660e01b81526004016107689594939291906122aa565b6000604051808303818589803b15801561078157600080fd5b5088f1158015610795573d6000803e3d6000fd5b5050505050508260a0015167ffffffffffffffff168360800151837f9c887f38b8f2330ee9894137eb60cf6ab904c5d2063ddc0baa7a77bfd1880e8c866000015187602001518860600151604051610800939291909283526020830191909152604082015260600190565b60405180910390a45050505050505050565b61081a61113c565b610824600061118f565b565b600061083188611204565b5061087184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec906108e8908b908a908a90600401612335565b602060405180830381865afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109299190612358565b905073ffffffffffffffffffffffffffffffffffffffff8716156109fd5760006109538484611294565b6040517fc473e7e800000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff89169063c473e7e8906109ae908c9085908a908a9060040161239c565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190612358565b6109f990836123f5565b9150505b979650505050505050565b6060610a13826112c3565b92915050565b604080516060810182526000808252602082018190529181019190915273ffffffffffffffffffffffffffffffffffffffff8916610a5e8b828b8b8b8b8b8b8b6112ec565b9b9a5050505050505050505050565b600081815260036020526040812054819073ffffffffffffffffffffffffffffffffffffffff1680610ace576040517fe99eb48d000000000000000000000000000000000000000000000000000000008152600481018590526024016104bc565b60008482604051602001610b0292919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60408051808303601f1901815290829052805160208201207f2ad8c706000000000000000000000000000000000000000000000000000000008352600483015291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632ad8c7069060240160408051808303816000875af1158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc79190612413565b60405173ffffffffffffffffffffffffffffffffffffffff85168152919550935067ffffffffffffffff841690859087907f810ecf3e461a7f5c46c0bbbca8680cf65de59e78e521d58d569e03969d08648c9060200160405180910390a45050915091565b6040805160608101825260008082526020820181905291810191909152610c5a8a8a8a8a8a8a8a8a8a6112ec565b9a9950505050505050505050565b6000468203610ca6576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060009081526002602052604090205490565b6040805180820190915260008082526020820152610a1382610e7d565b610cde61113c565b73ffffffffffffffffffffffffffffffffffffffff8116610d2e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016104bc565b610d378161118f565b50565b610d4261113c565b60008281526002602090815260409182902083905581518481529081018390527fb6b5dc04cc1c35fc7a8c8342e378dccc610c6589ef3bcfcd6eaf0304913f889a910160405180910390a15050565b600080610dd384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905060036000610de2836119c1565b815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16949350505050565b610e696040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b81806020019051810190610a139190612488565b6040805180820190915260008082526020820152600080610e9d846119f1565b9092509050600160ff83161015610ee5576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff831660048201526024016104bc565b80806020019051810190610ef9919061259d565b949350505050565b600080610f118560000151611204565b905046856040015114610f585784604001516040517f973253820000000000000000000000000000000000000000000000000000000081526004016104bc91815260200190565b610f61856119c1565b60008181526003602052604090205490925073ffffffffffffffffffffffffffffffffffffffff1615610fc3576040517fd80aeb91000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b60006040518060a0016040528087600001518152602001876080015181526020018760a0015167ffffffffffffffff168152602001838152602001848152509050600080611012886060015190565b73ffffffffffffffffffffffffffffffffffffffff1663287bc0576040518163ffffffff1660e01b8152600401600060405180830381865afa15801561105c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261108491908101906125b9565b91509150600061109383611a13565b80519091506000036110d1576040517fa09e214300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006110e483868b8b8660200151611a7b565b825190915081101561112f5781516040517f0bce4e850000000000000000000000000000000000000000000000000000000081526104bc918391600401918252602082015260400190565b5050505050509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610824576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104bc565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000468203611242576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b506000818152600260205260408120549081900361128f576040517f9a45110f000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b919050565b6000601f19601f830116601f19601f8501166112b2906101606123f5565b6112bc91906123f5565b9392505050565b6060816040516020016112d6919061268f565b6040516020818303038152906040529050919050565b60408051606081018252600080825260208201819052918101919091526113128a611204565b50600089900361134e576040517f0b3e41a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61138d85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec90611407908e908c908c90600401612335565b602060405180830381865afa158015611424573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114489190612358565b90508034101561148d576040517f9557ee49000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016104bc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aa2f06ae6040518163ffffffff1660e01b81526004016040805180830381865afa1580156114f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151b9190612413565b83602001846040018267ffffffffffffffff1667ffffffffffffffff1681525082815250505060006115d4338d8d866020015187604001518c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b8892505050565b90506115df816119c1565b8360000181815250506000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367c769af85856040015188600001518f8f6040518663ffffffff1660e01b81526004016116539493929190612710565b604080518083038185885af1158015611670573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116959190612413565b915091508460200151821480156116c35750846040015167ffffffffffffffff168167ffffffffffffffff16145b6116cf576116cf612730565b50503482810390831461177857600154604080840151865191517fffecec7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263ffecec7e92859261174592909190600401918252602082015260400190565b6000604051808303818588803b15801561175e57600080fd5b505af1158015611772573d6000803e3d6000fd5b50505050505b73ffffffffffffffffffffffffffffffffffffffff8b16156119415773ffffffffffffffffffffffffffffffffffffffff8b1663e4e065228e6117bb8a89611294565b87516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526117fe9392919087908f908f9060040161275f565b600060405180830381600087803b15801561181857600080fd5b505af115801561182c573d6000803e3d6000fd5b5050505060008b73ffffffffffffffffffffffffffffffffffffffff166362014bad6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561187d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a19190612797565b600154604085810151885191517f0676b7060000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915273ffffffffffffffffffffffffffffffffffffffff8084166044830152929350911690630676b70690606401600060405180830381600087803b15801561192757600080fd5b505af115801561193b573d6000803e3d6000fd5b50505050505b8160a0015167ffffffffffffffff16826080015185600001517f1b22d6c0b67f6f17a9004833bfb5afbaea4602457bd57e1d128cb997fb30161b85604001518660200151876060015189888a60c001518b60e001516040516119a997969594939291906127b4565b60405180910390a45050509998505050505050505050565b6000816040516020016119d4919061268f565b604051602081830303815290604052805190602001209050919050565b6000606082806020019051810190611a0991906127f7565b9094909350915050565b6040805180820190915260008082526020820152600080611a33846119f1565b9092509050600160ff83161015610ee5576040517fc3e3b66600000000000000000000000000000000000000000000000000000000815260ff831660048201526024016104bc565b6000805b8651811015611b7e5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367b1f42e898481518110611ad857611ad861284e565b60200260200101518989896040518563ffffffff1660e01b8152600401611b02949392919061287d565b602060405180830381865afa158015611b1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b439190612358565b90508015801590611b5c575042611b5a85836123f5565b105b15611b6d57611b6a83612928565b92505b50611b7781612928565b9050611a7f565b5095945050505050565b611be06040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b604051806101000160405280468152602001611c0f8a73ffffffffffffffffffffffffffffffffffffffff1690565b81526020018881526020018781526020018681526020018567ffffffffffffffff168152602001848152602001838152509050979650505050505050565b600060208284031215611c5f57600080fd5b5035919050565b60008083601f840112611c7857600080fd5b50813567ffffffffffffffff811115611c9057600080fd5b602083019150836020828501011115611ca857600080fd5b9250929050565b60008083601f840112611cc157600080fd5b50813567ffffffffffffffff811115611cd957600080fd5b6020830191508360208260051b8501011115611ca857600080fd5b60008060008060408587031215611d0a57600080fd5b843567ffffffffffffffff80821115611d2257600080fd5b611d2e88838901611c66565b90965094506020870135915080821115611d4757600080fd5b50611d5487828801611caf565b95989497509550505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d3757600080fd5b600060208284031215611d9457600080fd5b81356112bc81611d60565b600080600080600060608688031215611db757600080fd5b85359450602086013567ffffffffffffffff80821115611dd657600080fd5b611de289838a01611c66565b90965094506040880135915080821115611dfb57600080fd5b50611e0888828901611caf565b969995985093965092949392505050565b600080600080600080600060a0888a031215611e3457600080fd5b873596506020880135611e4681611d60565b9550604088013567ffffffffffffffff80821115611e6357600080fd5b611e6f8b838c01611caf565b909750955060608a0135915080821115611e8857600080fd5b50611e958a828b01611c66565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff81118282101715611f0157611f01611eae565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611f3057611f30611eae565b604052919050565b67ffffffffffffffff81168114610d3757600080fd5b803561128f81611f38565b600067ffffffffffffffff821115611f7357611f73611eae565b50601f01601f191660200190565b600082601f830112611f9257600080fd5b8135611fa5611fa082611f59565b611f07565b818152846020838601011115611fba57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215611fe957600080fd5b813567ffffffffffffffff8082111561200157600080fd5b90830190610100828603121561201657600080fd5b61201e611edd565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015261205660a08401611f4e565b60a082015260c08301358281111561206d57600080fd5b61207987828601611f81565b60c08301525060e08301358281111561209157600080fd5b61209d87828601611f81565b60e08301525095945050505050565b60005b838110156120c75781810151838201526020016120af565b50506000910152565b600081518084526120e88160208601602086016120ac565b601f01601f19169290920160200192915050565b6020815260006112bc60208301846120d0565b600080600080600080600080600060c08a8c03121561212d57600080fd5b8935985060208a013561213f81611d60565b975060408a013561214f81611d60565b965060608a013567ffffffffffffffff8082111561216c57600080fd5b6121788d838e01611caf565b909850965060808c013591508082111561219157600080fd5b61219d8d838e01611c66565b909650945060a08c01359150808211156121b657600080fd5b506121c38c828d01611c66565b915080935050809150509295985092959850929598565b600080600080600080600080600060c08a8c0312156121f857600080fd5b8935985060208a0135975060408a013561214f81611d60565b60006020828403121561222357600080fd5b813567ffffffffffffffff81111561223a57600080fd5b610ef984828501611f81565b6000806040838503121561225957600080fd5b50508035926020909101359150565b6000806020838503121561227b57600080fd5b823567ffffffffffffffff81111561229257600080fd5b61229e85828601611c66565b90969095509350505050565b85815284602082015283604082015267ffffffffffffffff8316606082015260a0608082015260006109fd60a08301846120d0565b8183526000602080850194508260005b8581101561232a57813561230281611d60565b73ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016122ef565b509495945050505050565b83815260406020820152600061234f6040830184866122df565b95945050505050565b60006020828403121561236a57600080fd5b5051919050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b8481528360208201526060604082015260006123bc606083018486612371565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610a1357610a136123c6565b805161128f81611f38565b6000806040838503121561242657600080fd5b82519150602083015161243881611f38565b809150509250929050565b600082601f83011261245457600080fd5b8151612462611fa082611f59565b81815284602083860101111561247757600080fd5b610ef98260208301602087016120ac565b60006020828403121561249a57600080fd5b815167ffffffffffffffff808211156124b257600080fd5b9083019061010082860312156124c757600080fd5b6124cf611edd565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015261250760a08401612408565b60a082015260c08301518281111561251e57600080fd5b61252a87828601612443565b60c08301525060e08301518281111561254257600080fd5b61209d87828601612443565b60006040828403121561256057600080fd5b6040516040810181811067ffffffffffffffff8211171561258357612583611eae565b604052825181526020928301519281019290925250919050565b6000604082840312156125af57600080fd5b6112bc838361254e565b600080604083850312156125cc57600080fd5b825167ffffffffffffffff808211156125e457600080fd5b6125f086838701612443565b935060209150818501518181111561260757600080fd5b8501601f8101871361261857600080fd5b80518281111561262a5761262a611eae565b8060051b925061263b848401611f07565b818152928201840192848101908985111561265557600080fd5b928501925b8484101561267f578351925061266f83611d60565b828252928501929085019061265a565b8096505050505050509250929050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015267ffffffffffffffff60a08301511660c0820152600060c08301516101008060e08501526126f46101208501836120d0565b915060e0850151601f1985840301828601526123bc83826120d0565b8481528360208201526060604082015260006123bc6060830184866122df565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b86815285602082015284604082015283606082015260a06080820152600061278b60a083018486612371565b98975050505050505050565b6000602082840312156127a957600080fd5b81516112bc81611d60565b87815286602082015285604082015284606082015283608082015260e060a082015260006127e560e08301856120d0565b82810360c0840152610c5a81856120d0565b6000806040838503121561280a57600080fd5b825160ff8116811461281b57600080fd5b602084015190925067ffffffffffffffff81111561283857600080fd5b61284485828601612443565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff85168152835160208201526020840151604082015267ffffffffffffffff604085015116606082015260608401516080820152608084015160a082015260e060c08201528160e082015260006101007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84111561290e57600080fd5b8360051b8086838601379290920190910195945050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612959576129596123c6565b506001019056fea264697066735822122091c22b0cc90fb32367eac5ecf5fc611ddfc546d213efc6b396bcb06086bbe0b564736f6c63430008140033","runtime-code":"0x6080604052600436106101445760003560e01c80638da5cb5b116100c0578063e4c6124711610074578063f2fde38b11610059578063f2fde38b14610422578063f34234c814610442578063f92a79ff1461046257600080fd5b8063e4c61247146103ab578063f1a61fac146103df57600080fd5b806398939d28116100a557806398939d281461033d578063aa102ec414610350578063d5e788a01461037057600080fd5b80638da5cb5b146102d457806390e81077146102ff57600080fd5b8063715018a6116101175780637a1277db116100fc5780637a1277db1461023a5780637c80a90f14610268578063827f940d1461029557600080fd5b8063715018a6146101f85780637341eaf91461020d57600080fd5b806302172a35146101495780631450c281146101935780633dc68b87146101c357806353b67d74146101e5575b600080fd5b34801561015557600080fd5b50610169610164366004611c4d565b610482565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561019f57600080fd5b506101b36101ae366004611cf4565b61052e565b604051901515815260200161018a565b3480156101cf57600080fd5b506101e36101de366004611d82565b610598565b005b6101e36101f3366004611d9f565b610619565b34801561020457600080fd5b506101e3610812565b34801561021957600080fd5b506001546101699073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024657600080fd5b5061025a610255366004611e19565b610826565b60405190815260200161018a565b34801561027457600080fd5b50610288610283366004611fd7565b610a08565b60405161018a91906120fc565b6102a86102a336600461210f565b610a19565b6040805182518152602080840151908201529181015167ffffffffffffffff169082015260600161018a565b3480156102e057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610169565b34801561030b57600080fd5b5061031f61031a366004611c4d565b610a6d565b6040805192835267ffffffffffffffff90911660208301520161018a565b6102a861034b3660046121da565b610c2c565b34801561035c57600080fd5b5061025a61036b366004611c4d565b610c68565b34801561037c57600080fd5b5061039061038b366004612211565b610cb9565b6040805182518152602092830151928101929092520161018a565b3480156103b757600080fd5b506101697f000000000000000000000000000000000000000000000000000000000000000081565b3480156103eb57600080fd5b506101696103fa366004611c4d565b60009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b34801561042e57600080fd5b506101e361043d366004611d82565b610cd6565b34801561044e57600080fd5b506101e361045d366004612246565b610d3a565b34801561046e57600080fd5b5061016961047d366004612268565b610d91565b60004682036104c5576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b506000818152600260205260409020548073ffffffffffffffffffffffffffffffffffffffff81168114610528576040517f0a55a4eb000000000000000000000000000000000000000000000000000000008152600481018290526024016104bc565b50919050565b60008061057086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905061057f8160c00151610e7d565b5061058b818585610f01565b5060019695505050505050565b6105a061113c565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fec02f15d78cdfc4beeba45f31cfad25089004e5e3d72727168dd96a77d1f2f829060200160405180910390a150565b600061065a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b90506000610669828585610f01565b600081815260036020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317905560c0840151919250906106b190610e7d565b9050806020015134146106ff5760208101516040517f2b36102500000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016104bc565b805188101561070d57805197505b606083015173ffffffffffffffffffffffffffffffffffffffff166368a6984789348660000151876020015188608001518960a001518a60e001516040518863ffffffff1660e01b81526004016107689594939291906122aa565b6000604051808303818589803b15801561078157600080fd5b5088f1158015610795573d6000803e3d6000fd5b5050505050508260a0015167ffffffffffffffff168360800151837f9c887f38b8f2330ee9894137eb60cf6ab904c5d2063ddc0baa7a77bfd1880e8c866000015187602001518860600151604051610800939291909283526020830191909152604082015260600190565b60405180910390a45050505050505050565b61081a61113c565b610824600061118f565b565b600061083188611204565b5061087184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec906108e8908b908a908a90600401612335565b602060405180830381865afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109299190612358565b905073ffffffffffffffffffffffffffffffffffffffff8716156109fd5760006109538484611294565b6040517fc473e7e800000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff89169063c473e7e8906109ae908c9085908a908a9060040161239c565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef9190612358565b6109f990836123f5565b9150505b979650505050505050565b6060610a13826112c3565b92915050565b604080516060810182526000808252602082018190529181019190915273ffffffffffffffffffffffffffffffffffffffff8916610a5e8b828b8b8b8b8b8b8b6112ec565b9b9a5050505050505050505050565b600081815260036020526040812054819073ffffffffffffffffffffffffffffffffffffffff1680610ace576040517fe99eb48d000000000000000000000000000000000000000000000000000000008152600481018590526024016104bc565b60008482604051602001610b0292919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60408051808303601f1901815290829052805160208201207f2ad8c706000000000000000000000000000000000000000000000000000000008352600483015291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632ad8c7069060240160408051808303816000875af1158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc79190612413565b60405173ffffffffffffffffffffffffffffffffffffffff85168152919550935067ffffffffffffffff841690859087907f810ecf3e461a7f5c46c0bbbca8680cf65de59e78e521d58d569e03969d08648c9060200160405180910390a45050915091565b6040805160608101825260008082526020820181905291810191909152610c5a8a8a8a8a8a8a8a8a8a6112ec565b9a9950505050505050505050565b6000468203610ca6576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060009081526002602052604090205490565b6040805180820190915260008082526020820152610a1382610e7d565b610cde61113c565b73ffffffffffffffffffffffffffffffffffffffff8116610d2e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016104bc565b610d378161118f565b50565b610d4261113c565b60008281526002602090815260409182902083905581518481529081018390527fb6b5dc04cc1c35fc7a8c8342e378dccc610c6589ef3bcfcd6eaf0304913f889a910160405180910390a15050565b600080610dd384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905060036000610de2836119c1565b815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16949350505050565b610e696040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b81806020019051810190610a139190612488565b6040805180820190915260008082526020820152600080610e9d846119f1565b9092509050600160ff83161015610ee5576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff831660048201526024016104bc565b80806020019051810190610ef9919061259d565b949350505050565b600080610f118560000151611204565b905046856040015114610f585784604001516040517f973253820000000000000000000000000000000000000000000000000000000081526004016104bc91815260200190565b610f61856119c1565b60008181526003602052604090205490925073ffffffffffffffffffffffffffffffffffffffff1615610fc3576040517fd80aeb91000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b60006040518060a0016040528087600001518152602001876080015181526020018760a0015167ffffffffffffffff168152602001838152602001848152509050600080611012886060015190565b73ffffffffffffffffffffffffffffffffffffffff1663287bc0576040518163ffffffff1660e01b8152600401600060405180830381865afa15801561105c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261108491908101906125b9565b91509150600061109383611a13565b80519091506000036110d1576040517fa09e214300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006110e483868b8b8660200151611a7b565b825190915081101561112f5781516040517f0bce4e850000000000000000000000000000000000000000000000000000000081526104bc918391600401918252602082015260400190565b5050505050509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610824576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104bc565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000468203611242576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b506000818152600260205260408120549081900361128f576040517f9a45110f000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b919050565b6000601f19601f830116601f19601f8501166112b2906101606123f5565b6112bc91906123f5565b9392505050565b6060816040516020016112d6919061268f565b6040516020818303038152906040529050919050565b60408051606081018252600080825260208201819052918101919091526113128a611204565b50600089900361134e576040517f0b3e41a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61138d85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec90611407908e908c908c90600401612335565b602060405180830381865afa158015611424573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114489190612358565b90508034101561148d576040517f9557ee49000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016104bc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aa2f06ae6040518163ffffffff1660e01b81526004016040805180830381865afa1580156114f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151b9190612413565b83602001846040018267ffffffffffffffff1667ffffffffffffffff1681525082815250505060006115d4338d8d866020015187604001518c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611b8892505050565b90506115df816119c1565b8360000181815250506000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367c769af85856040015188600001518f8f6040518663ffffffff1660e01b81526004016116539493929190612710565b604080518083038185885af1158015611670573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116959190612413565b915091508460200151821480156116c35750846040015167ffffffffffffffff168167ffffffffffffffff16145b6116cf576116cf612730565b50503482810390831461177857600154604080840151865191517fffecec7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263ffecec7e92859261174592909190600401918252602082015260400190565b6000604051808303818588803b15801561175e57600080fd5b505af1158015611772573d6000803e3d6000fd5b50505050505b73ffffffffffffffffffffffffffffffffffffffff8b16156119415773ffffffffffffffffffffffffffffffffffffffff8b1663e4e065228e6117bb8a89611294565b87516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526117fe9392919087908f908f9060040161275f565b600060405180830381600087803b15801561181857600080fd5b505af115801561182c573d6000803e3d6000fd5b5050505060008b73ffffffffffffffffffffffffffffffffffffffff166362014bad6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561187d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118a19190612797565b600154604085810151885191517f0676b7060000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915273ffffffffffffffffffffffffffffffffffffffff8084166044830152929350911690630676b70690606401600060405180830381600087803b15801561192757600080fd5b505af115801561193b573d6000803e3d6000fd5b50505050505b8160a0015167ffffffffffffffff16826080015185600001517f1b22d6c0b67f6f17a9004833bfb5afbaea4602457bd57e1d128cb997fb30161b85604001518660200151876060015189888a60c001518b60e001516040516119a997969594939291906127b4565b60405180910390a45050509998505050505050505050565b6000816040516020016119d4919061268f565b604051602081830303815290604052805190602001209050919050565b6000606082806020019051810190611a0991906127f7565b9094909350915050565b6040805180820190915260008082526020820152600080611a33846119f1565b9092509050600160ff83161015610ee5576040517fc3e3b66600000000000000000000000000000000000000000000000000000000815260ff831660048201526024016104bc565b6000805b8651811015611b7e5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367b1f42e898481518110611ad857611ad861284e565b60200260200101518989896040518563ffffffff1660e01b8152600401611b02949392919061287d565b602060405180830381865afa158015611b1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b439190612358565b90508015801590611b5c575042611b5a85836123f5565b105b15611b6d57611b6a83612928565b92505b50611b7781612928565b9050611a7f565b5095945050505050565b611be06040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b604051806101000160405280468152602001611c0f8a73ffffffffffffffffffffffffffffffffffffffff1690565b81526020018881526020018781526020018681526020018567ffffffffffffffff168152602001848152602001838152509050979650505050505050565b600060208284031215611c5f57600080fd5b5035919050565b60008083601f840112611c7857600080fd5b50813567ffffffffffffffff811115611c9057600080fd5b602083019150836020828501011115611ca857600080fd5b9250929050565b60008083601f840112611cc157600080fd5b50813567ffffffffffffffff811115611cd957600080fd5b6020830191508360208260051b8501011115611ca857600080fd5b60008060008060408587031215611d0a57600080fd5b843567ffffffffffffffff80821115611d2257600080fd5b611d2e88838901611c66565b90965094506020870135915080821115611d4757600080fd5b50611d5487828801611caf565b95989497509550505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d3757600080fd5b600060208284031215611d9457600080fd5b81356112bc81611d60565b600080600080600060608688031215611db757600080fd5b85359450602086013567ffffffffffffffff80821115611dd657600080fd5b611de289838a01611c66565b90965094506040880135915080821115611dfb57600080fd5b50611e0888828901611caf565b969995985093965092949392505050565b600080600080600080600060a0888a031215611e3457600080fd5b873596506020880135611e4681611d60565b9550604088013567ffffffffffffffff80821115611e6357600080fd5b611e6f8b838c01611caf565b909750955060608a0135915080821115611e8857600080fd5b50611e958a828b01611c66565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff81118282101715611f0157611f01611eae565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611f3057611f30611eae565b604052919050565b67ffffffffffffffff81168114610d3757600080fd5b803561128f81611f38565b600067ffffffffffffffff821115611f7357611f73611eae565b50601f01601f191660200190565b600082601f830112611f9257600080fd5b8135611fa5611fa082611f59565b611f07565b818152846020838601011115611fba57600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215611fe957600080fd5b813567ffffffffffffffff8082111561200157600080fd5b90830190610100828603121561201657600080fd5b61201e611edd565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015261205660a08401611f4e565b60a082015260c08301358281111561206d57600080fd5b61207987828601611f81565b60c08301525060e08301358281111561209157600080fd5b61209d87828601611f81565b60e08301525095945050505050565b60005b838110156120c75781810151838201526020016120af565b50506000910152565b600081518084526120e88160208601602086016120ac565b601f01601f19169290920160200192915050565b6020815260006112bc60208301846120d0565b600080600080600080600080600060c08a8c03121561212d57600080fd5b8935985060208a013561213f81611d60565b975060408a013561214f81611d60565b965060608a013567ffffffffffffffff8082111561216c57600080fd5b6121788d838e01611caf565b909850965060808c013591508082111561219157600080fd5b61219d8d838e01611c66565b909650945060a08c01359150808211156121b657600080fd5b506121c38c828d01611c66565b915080935050809150509295985092959850929598565b600080600080600080600080600060c08a8c0312156121f857600080fd5b8935985060208a0135975060408a013561214f81611d60565b60006020828403121561222357600080fd5b813567ffffffffffffffff81111561223a57600080fd5b610ef984828501611f81565b6000806040838503121561225957600080fd5b50508035926020909101359150565b6000806020838503121561227b57600080fd5b823567ffffffffffffffff81111561229257600080fd5b61229e85828601611c66565b90969095509350505050565b85815284602082015283604082015267ffffffffffffffff8316606082015260a0608082015260006109fd60a08301846120d0565b8183526000602080850194508260005b8581101561232a57813561230281611d60565b73ffffffffffffffffffffffffffffffffffffffff16875295820195908201906001016122ef565b509495945050505050565b83815260406020820152600061234f6040830184866122df565b95945050505050565b60006020828403121561236a57600080fd5b5051919050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b8481528360208201526060604082015260006123bc606083018486612371565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610a1357610a136123c6565b805161128f81611f38565b6000806040838503121561242657600080fd5b82519150602083015161243881611f38565b809150509250929050565b600082601f83011261245457600080fd5b8151612462611fa082611f59565b81815284602083860101111561247757600080fd5b610ef98260208301602087016120ac565b60006020828403121561249a57600080fd5b815167ffffffffffffffff808211156124b257600080fd5b9083019061010082860312156124c757600080fd5b6124cf611edd565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015261250760a08401612408565b60a082015260c08301518281111561251e57600080fd5b61252a87828601612443565b60c08301525060e08301518281111561254257600080fd5b61209d87828601612443565b60006040828403121561256057600080fd5b6040516040810181811067ffffffffffffffff8211171561258357612583611eae565b604052825181526020928301519281019290925250919050565b6000604082840312156125af57600080fd5b6112bc838361254e565b600080604083850312156125cc57600080fd5b825167ffffffffffffffff808211156125e457600080fd5b6125f086838701612443565b935060209150818501518181111561260757600080fd5b8501601f8101871361261857600080fd5b80518281111561262a5761262a611eae565b8060051b925061263b848401611f07565b818152928201840192848101908985111561265557600080fd5b928501925b8484101561267f578351925061266f83611d60565b828252928501929085019061265a565b8096505050505050509250929050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015267ffffffffffffffff60a08301511660c0820152600060c08301516101008060e08501526126f46101208501836120d0565b915060e0850151601f1985840301828601526123bc83826120d0565b8481528360208201526060604082015260006123bc6060830184866122df565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b86815285602082015284604082015283606082015260a06080820152600061278b60a083018486612371565b98975050505050505050565b6000602082840312156127a957600080fd5b81516112bc81611d60565b87815286602082015285604082015284606082015283608082015260e060a082015260006127e560e08301856120d0565b82810360c0840152610c5a81856120d0565b6000806040838503121561280a57600080fd5b825160ff8116811461281b57600080fd5b602084015190925067ffffffffffffffff81111561283857600080fd5b61284485828601612443565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff85168152835160208201526020840151604082015267ffffffffffffffff604085015116606082015260608401516080820152608084015160a082015260e060c08201528160e082015260006101007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84111561290e57600080fd5b8360051b8086838601379290920190910195945050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612959576129596123c6565b506001019056fea264697066735822122091c22b0cc90fb32367eac5ecf5fc611ddfc546d213efc6b396bcb06086bbe0b564736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"40929:15002:0:-:0;;;41674:111;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;41732:6;-1:-1:-1;;;;;19764:26:0;;19760:95;;19813:31;;-1:-1:-1;;;19813:31:0;;19841:1;19813:31;;;640:51:1;613:18;;19813:31:0;;;;;;;19760:95;19864:32;19883:12;19864:18;:32::i;:::-;-1:-1:-1;;;;;;;41750:28:0::1;;::::0;40929:15002;;21403:187;21476:16;21495:6;;-1:-1:-1;;;;;21511:17:0;;;-1:-1:-1;;;;;;21511:17:0;;;;;;21543:40;;21495:6;;;;;;;21543:40;;21476:16;21543:40;21466:124;21403:187;:::o;14:177:1:-;93:13;;-1:-1:-1;;;;;135:31:1;;125:42;;115:70;;181:1;178;171:12;115:70;14:177;;;:::o;196:293::-;275:6;283;336:2;324:9;315:7;311:23;307:32;304:52;;;352:1;349;342:12;304:52;375:40;405:9;375:40;:::i;:::-;365:50;;434:49;479:2;468:9;464:18;434:49;:::i;:::-;424:59;;196:293;;;;;:::o;494:203::-;40929:15002:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"40929:15002:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;47849:571;;;;;;;;;;-1:-1:-1;47849:571:0;;;;;:::i;:::-;;:::i;:::-;;;375:42:1;363:55;;;345:74;;333:2;318:18;47849:571:0;;;;;;;;45792:357;;;;;;;;;;-1:-1:-1;45792:357:0;;;;;:::i;:::-;;:::i;:::-;;;2069:14:1;;2062:22;2044:41;;2032:2;2017:18;45792:357:0;1904:187:1;41830:163:0;;;;;;;;;;-1:-1:-1;41830:163:0;;;;;:::i;:::-;;:::i;:::-;;43398:1445;;;;;;:::i;:::-;;:::i;20784:101::-;;;;;;;;;;;;;:::i;41316:28::-;;;;;;;;;;-1:-1:-1;41316:28:0;;;;;;;;46649:872;;;;;;;;;;-1:-1:-1;46649:872:0;;;;;:::i;:::-;;:::i;:::-;;;4494:25:1;;;4482:2;4467:18;46649:872:0;4348:177:1;48492:147:0;;;;;;;;;;-1:-1:-1;48492:147:0;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;42726:508::-;;;;;;:::i;:::-;;:::i;:::-;;;;9904:13:1;;9886:32;;9974:4;9962:17;;;9956:24;9934:20;;;9927:54;10029:17;;;10023:24;10049:18;10019:49;9997:20;;;9990:79;9874:2;9859:18;42726:508:0;9662:413:1;20129:85:0;;;;;;;;;;-1:-1:-1;20175:7:0;20201:6;;;20129:85;;44889:524;;;;;;;;;;-1:-1:-1;44889:524:0;;;;;:::i;:::-;;:::i;:::-;;;;10437:25:1;;;10510:18;10498:31;;;10493:2;10478:18;;10471:59;10410:18;44889:524:0;10265:271:1;42255:426:0;;;;;;:::i;:::-;;:::i;47567:236::-;;;;;;;;;;-1:-1:-1;47567:236:0;;;;;:::i;:::-;;:::i;48719:149::-;;;;;;;;;;-1:-1:-1;48719:149:0;;;;;:::i;:::-;;:::i;:::-;;;;12575:13:1;;12557:32;;12645:4;12633:17;;;12627:24;12605:20;;;12598:54;;;;12530:18;48719:149:0;12359:299:1;41173:38:0;;;;;;;;;;;;;;;46474:130;;;;;;;;;;-1:-1:-1;46474:130:0;;;;;:::i;:::-;46545:7;46571:26;;;:11;:26;;;;;;;;;46474:130;21034:215;;;;;;;;;;-1:-1:-1;21034:215:0;;;;;:::i;:::-;;:::i;42038:172::-;;;;;;;;;;-1:-1:-1;42038:172:0;;;;;:::i;:::-;;:::i;46194:235::-;;;;;;;;;;-1:-1:-1;46194:235:0;;;;;:::i;:::-;;:::i;47849:571::-;47917:23;47967:13;47956:7;:24;47952:107;;48003:45;;;;;;;;4494:25:1;;;4467:18;;48003:45:0;;;;;;;;47952:107;-1:-1:-1;48068:20:0;48091:22;;;:13;:22;;;;;;;14949;;;48275:59;;48271:143;;48357:46;;;;;;;;4494:25:1;;;4467:18;;48357:46:0;4348:177:1;48271:143:0;47942:478;47849:571;;;:::o;45792:357::-;45889:4;45905:33;45941:53;45984:9;;45941:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;45941:42:0;;-1:-1:-1;;;45941:53:0:i;:::-;45905:89;;46051:30;:4;:12;;;:28;:30::i;:::-;;46091;46109:4;46115:5;;46091:17;:30::i;:::-;-1:-1:-1;46138:4:0;;45792:357;-1:-1:-1;;;;;;45792:357:0:o;41830:163::-;20022:13;:11;:13::i;:::-;41909::::1;:30:::0;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;41954:32:::1;::::0;345:74:1;;;41954:32:0::1;::::0;333:2:1;318:18;41954:32:0::1;;;;;;;41830:163:::0;:::o;43398:1445::-;43574:33;43610:55;43653:11;;43610:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;43610:42:0;;-1:-1:-1;;;43610:55:0:i;:::-;43574:91;;43675:21;43699:30;43717:4;43723:5;;43699:17;:30::i;:::-;43739:26;;;;:11;:26;;;;;:39;;;;43768:10;43739:39;;;43823:12;;;;43675:54;;-1:-1:-1;43739:26:0;43823:30;;:28;:30::i;:::-;43789:64;;43880:14;:25;;;43867:9;:38;43863:151;;43977:25;;;;43928:75;;;;;43966:9;43928:75;;;13504:25:1;13545:18;;;13538:34;;;;13477:18;;43928:75:0;13330:248:1;43863:151:0;44175:23;;:34;-1:-1:-1;44171:74:0;;;44222:23;;;-1:-1:-1;44171:74:0;44411:16;;;;44369:71;;;44446:8;44463:9;44500:4;:15;;;44537:4;:14;;;44574:4;:12;;;44612:4;:15;;;44650:4;:12;;;44369:304;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;44760:4;:15;;;44688:148;;44746:4;:12;;;44731:13;44688:148;44777:4;:15;;;44794:4;:14;;;44810:4;:16;;;44688:148;;;;;;;14317:25:1;;;14373:2;14358:18;;14351:34;;;;14416:2;14401:18;;14394:34;14305:2;14290:18;;14115:319;44688:148:0;;;;;;;;43564:1279;;;43398:1445;;;;;:::o;20784:101::-;20022:13;:11;:13::i;:::-;20848:30:::1;20875:1;20848:18;:30::i;:::-;20784:101::o:0;46649:872::-;46892:11;46919:31;46939:10;46919:19;:31::i;:::-;;47028:25;:7;;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;47028:23:0;;-1:-1:-1;;;47028:25:0:i;:::-;-1:-1:-1;47115:69:0;;;;;:45;47129:13;47115:45;;;;:69;;47161:10;;47173;;;;47115:69;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;47109:75;-1:-1:-1;47260:33:0;;;;47256:259;;47309:19;47331:64;47368:7;47384:10;47331:36;:64::i;:::-;47416:88;;;;;47309:86;;-1:-1:-1;47416:54:0;;;;;;:88;;47471:10;;47309:86;;47496:7;;;;47416:88;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;47409:95;;;;:::i;:::-;;;47295:220;47256:259;46649:872;;;;;;;;;:::o;48492:147::-;48577:12;48608:24;:4;:22;:24::i;:::-;48601:31;48492:147;-1:-1:-1;;48492:147:0:o;42726:508::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;14949:22:0;;;43132:95;43148:10;14949:22;43177:19;43198:10;;43210:7;;43219;;43132:15;:95::i;:::-;43125:102;42726:508;-1:-1:-1;;;;;;;;;;;42726:508:0:o;44889:524::-;44959:15;45024:26;;;:11;:26;;;;;;44959:15;;45024:26;;;45060:108;;45109:48;;;;;;;;4494:25:1;;;4467:18;;45109:48:0;4348:177:1;45060:108:0;45177:18;45209:13;45224:8;45198:35;;;;;;;;16756:25:1;;;16829:42;16817:55;16812:2;16797:18;;16790:83;16744:2;16729:18;;16582:297;45198:35:0;;;;;;;-1:-1:-1;;45198:35:0;;;;;;;45307:16;;45198:35;45307:16;;;45267:57;;;;;;4494:25:1;45198:35:0;-1:-1:-1;45281:13:0;45267:39;;;;;4467:18:1;;45267:57:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;45339:67;;375:42:1;363:55;;345:74;;45243:81:0;;-1:-1:-1;45243:81:0;-1:-1:-1;45339:67:0;;;;45243:81;;45361:13;;45339:67;;333:2:1;318:18;45339:67:0;;;;;;;44995:418;;44889:524;;;:::o;42255:426::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;42586:88:0;42602:10;42614:8;42624:19;42645:10;;42657:7;;42666;;42586:15;:88::i;:::-;42579:95;42255:426;-1:-1:-1;;;;;;;;;;42255:426:0:o;47567:236::-;47632:7;47666:13;47655:7;:24;47651:107;;47702:45;;;;;;;;4494:25:1;;;4467:18;;47702:45:0;4348:177:1;47651:107:0;-1:-1:-1;47774:22:0;;;;:13;:22;;;;;;;47567:236::o;48719:149::-;-1:-1:-1;;;;;;;;;;;;;;;;;48829:32:0;:14;:30;:32::i;21034:215::-;20022:13;:11;:13::i;:::-;21118:22:::1;::::0;::::1;21114:91;;21163:31;::::0;::::1;::::0;;21191:1:::1;21163:31;::::0;::::1;345:74:1::0;318:18;;21163:31:0::1;199:226:1::0;21114:91:0::1;21214:28;21233:8;21214:18;:28::i;:::-;21034:215:::0;:::o;42038:172::-;20022:13;:11;:13::i;:::-;42125:22:::1;::::0;;;:13:::1;:22;::::0;;;;;;;;:31;;;42171:32;;13504:25:1;;;13545:18;;;13538:34;;;42171:32:0::1;::::0;13477:18:1;42171:32:0::1;;;;;;;42038:172:::0;;:::o;46194:235::-;46264:7;46283:33;46319:53;46362:9;;46319:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;46319:42:0;;-1:-1:-1;;;46319:53:0:i;:::-;46283:89;;46389:11;:33;46401:20;:4;:18;:20::i;:::-;46389:33;;;;;;;;;;;-1:-1:-1;46389:33:0;;;;;46194:235;-1:-1:-1;;;;46194:235:0:o;22947:174::-;23021:28;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23021:28:0;23079:9;23068:46;;;;;;;;;;;;:::i;14188:603::-;-1:-1:-1;;;;;;;;;;;;;;;;;14284:13:0;14299:20;14323:28;14346:4;14323:22;:28::i;:::-;14283:68;;-1:-1:-1;14283:68:0;-1:-1:-1;12888:1:0;14365:20;;;;14361:95;;;14408:37;;;;;19360:4:1;19348:17;;14408:37:0;;;19330:36:1;19303:18;;14408:37:0;19188:184:1;14361:95:0;14763:7;14752:32;;;;;;;;;;;;:::i;:::-;14745:39;14188:603;-1:-1:-1;;;;14188:603:0:o;52664:1563::-;52821:21;52858:20;52881:36;52901:4;:15;;;52881:19;:36::i;:::-;52858:59;;52950:13;52931:4;:15;;;:32;52927:126;;53026:4;:15;;;52986:56;;;;;;;;;4494:25:1;;4482:2;4467:18;;4348:177;52927:126:0;53078:20;:4;:18;:20::i;:::-;53150:1;53112:26;;;:11;:26;;;;;;53062:36;;-1:-1:-1;53112:40:0;:26;:40;53108:130;;53175:52;;;;;;;;4494:25:1;;;4467:18;;53175:52:0;4348:177:1;53108:130:0;53311:30;53344:218;;;;;;;;53386:4;:15;;;53344:218;;;;53424:4;:12;;;53344:218;;;;53462:4;:15;;;53344:218;;;;;;53502:12;53344:218;;;;53538:13;53344:218;;;53311:251;;53573:29;53604:35;53670:44;53697:4;:16;;;15095:1;14985:121;53670:44;53655:79;;;:81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;53655:81:0;;;;;;;;;;;;:::i;:::-;53572:164;;;;53746:28;53777:36;:16;:34;:36::i;:::-;53827:27;;53746:67;;-1:-1:-1;53827:27:0;:32;53823:113;;53882:43;;;;;;;;;;;;;;53823:113;53945:17;53965:91;53993:18;54013:7;54022:5;;54029:9;:26;;;53965:27;:91::i;:::-;54082:27;;53945:111;;-1:-1:-1;54070:39:0;;54066:155;;;54182:27;;54132:78;;;;;;;54171:9;;54132:78;;13504:25:1;;;13560:2;13545:18;;13538:34;13492:2;13477:18;;13330:248;54066:155:0;52848:1379;;;;;;52664:1563;;;;;:::o;20287:162::-;20175:7;20201:6;20346:23;20201:6;15846:10;20346:23;20342:101;;20392:40;;;;;15846:10;20392:40;;;345:74:1;318:18;;20392:40:0;199:226:1;21403:187:0;21476:16;21495:6;;;21511:17;;;;;;;;;;21543:40;;21495:6;;;;;;;21543:40;;21476:16;21543:40;21466:124;21403:187;:::o;54318:368::-;54387:20;54434:13;54423:7;:24;54419:107;;54470:45;;;;;;;;4494:25:1;;;4467:18;;54470:45:0;4348:177:1;54419:107:0;-1:-1:-1;54550:22:0;;;;:13;:22;;;;;;;54586:17;;;54582:98;;54626:43;;;;;;;;4494:25:1;;;4467:18;;54626:43:0;4348:177:1;54582:98:0;54318:368;;;:::o;23127:506::-;23211:7;-1:-1:-1;;12294:2:0;12275:6;;12274:23;-1:-1:-1;;12294:2:0;12275:6;;12274:23;23565:32;;:3;:32;:::i;:::-;:61;;;;:::i;:::-;23558:68;23127:506;-1:-1:-1;;;23127:506:0:o;22788:153::-;22880:12;22922:11;22911:23;;;;;;;;:::i;:::-;;;;;;;;;;;;;22904:30;;22788:153;;;:::o;49270:2966::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;49579:31:0;49599:10;49579:19;:31::i;:::-;-1:-1:-1;49636:1:0;49624:13;;;49620:60;;49646:34;;;;;;;;;;;;;;49620:60;49758:25;:7;;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;49758:23:0;;-1:-1:-1;;;49758:25:0:i;:::-;-1:-1:-1;49819:69:0;;;;;49793:23;;49819:45;49833:13;49819:45;;;;:69;;49865:10;;49877;;;;49819:69;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;49793:95;;49914:15;49902:9;:27;49898:128;;;49952:63;;;;;49988:9;49952:63;;;13504:25:1;13545:18;;;13538:34;;;13477:18;;49952:63:0;13330:248:1;49898:128:0;50083:13;50069:46;;;:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;50036:4;:12;;50050:4;:15;;50035:82;;;;;;;;;;;;;;50127:33;50163:304;50239:10;50310;50276:8;50343:4;:12;;;50381:4;:15;;;50419:7;;50163:304;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;50449:7;;50163:304;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;50163:50:0;;-1:-1:-1;;;50163:304:0:i;:::-;50127:340;;50498:20;:4;:18;:20::i;:::-;50477:4;:18;;:41;;;;;50648:15;50665:17;50700:13;50686:55;;;50766:15;50796:4;:15;;;50813:4;:18;;;50833:10;;50686:158;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;50647:197;;;;50876:4;:12;;;50865:7;:23;:56;;;;;50906:4;:15;;;50892:29;;:10;:29;;;50865:56;50858:64;;;;:::i;:::-;-1:-1:-1;;51011:9:0;:27;;;;51062:16;;51058:150;;51109:13;;51161:15;;;;;51178:18;;51094:103;;;;;51109:13;;;;;51094:45;;51147:12;;51094:103;;51161:15;;51178:18;51094:103;;13504:25:1;;;13560:2;13545:18;;13538:34;13492:2;13477:18;;13330:248;51094:103:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;51058:150;51296:33;;;;51292:607;;51345:55;;;;51431:10;51474:68;51511:7;51527;51474:36;:68::i;:::-;51575:18;;51345:341;;;;;;;;;;;;;;51575:18;51625:12;;51664:7;;;;51345:341;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;51700:22;51743:19;51725:50;;;:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;51806:13;;51836:15;;;;;51853:18;;51791:97;;;;;;;;23978:25:1;;;;24019:18;;;24012:34;;;;51806:13:0;24082:55:1;;;24062:18;;;24055:83;51700:77:0;;-1:-1:-1;51806:13:0;;;51791:44;;23951:18:1;;51791:97:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;51331:568;51292:607;52010:4;:15;;;51913:316;;51984:4;:12;;;51952:4;:18;;;51913:316;52039:4;:15;;;52068:4;:14;;;52096:4;:16;;;52126:15;52155:12;52181:4;:12;;;52207:4;:12;;;51913:316;;;;;;;;;;;;:::i;:::-;;;;;;;;49569:2667;;;49270:2966;;;;;;;;;;;:::o;23639:155::-;23727:7;23774:11;23763:23;;;;;;;;:::i;:::-;;;;;;;;;;;;;23753:34;;;;;;23746:41;;23639:155;;;:::o;13559:181::-;13633:13;13648:20;13712:4;13701:32;;;;;;;;;;;;:::i;:::-;13680:53;;;;-1:-1:-1;13559:181:0;-1:-1:-1;;13559:181:0:o;9769:620::-;-1:-1:-1;;;;;;;;;;;;;;;;;9869:13:0;9884:22;9910:30;9935:4;9910:24;:30::i;:::-;9868:72;;-1:-1:-1;9868:72:0;-1:-1:-1;8377:1:0;9954:23;;;;9950:100;;;10000:39;;;;;19360:4:1;19348:17;;10000:39:0;;;19330:36:1;19303:18;;10000:39:0;19188:184:1;55199:730:0;55439:26;;55481:442;55505:15;:22;55501:1;:26;55481:442;;;55548:19;55584:13;55570:46;;;55617:15;55633:1;55617:18;;;;;;;;:::i;:::-;;;;;;;55637:7;55646:5;;55570:82;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;55548:104;-1:-1:-1;55790:16:0;;;;;:68;;-1:-1:-1;55843:15:0;55810:30;55824:16;55810:11;:30;:::i;:::-;:48;55790:68;55786:127;;;55878:20;;;:::i;:::-;;;55786:127;-1:-1:-1;55529:3:0;;;:::i;:::-;;;55481:442;;;;55199:730;;;;;;;:::o;22094:688::-;22378:40;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;22378:40:0;22441:334;;;;;;;;22489:13;22441:334;;;;22527:37;22554:9;14949:22;;;14852:127;22527:37;22441:334;;;;22590:10;22441:334;;;;22627:11;22441:334;;;;22661:7;22441:334;;;;22694:10;22441:334;;;;;;22727:7;22441:334;;;;22757:7;22441:334;;;22434:341;;22094:688;;;;;;;;;:::o;14:180:1:-;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;-1:-1:-1;165:23:1;;14:180;-1:-1:-1;14:180:1:o;430:347::-;481:8;491:6;545:3;538:4;530:6;526:17;522:27;512:55;;563:1;560;553:12;512:55;-1:-1:-1;586:20:1;;629:18;618:30;;615:50;;;661:1;658;651:12;615:50;698:4;690:6;686:17;674:29;;750:3;743:4;734:6;726;722:19;718:30;715:39;712:59;;;767:1;764;757:12;712:59;430:347;;;;;:::o;782:367::-;845:8;855:6;909:3;902:4;894:6;890:17;886:27;876:55;;927:1;924;917:12;876:55;-1:-1:-1;950:20:1;;993:18;982:30;;979:50;;;1025:1;1022;1015:12;979:50;1062:4;1054:6;1050:17;1038:29;;1122:3;1115:4;1105:6;1102:1;1098:14;1090:6;1086:27;1082:38;1079:47;1076:67;;;1139:1;1136;1129:12;1154:745;1260:6;1268;1276;1284;1337:2;1325:9;1316:7;1312:23;1308:32;1305:52;;;1353:1;1350;1343:12;1305:52;1393:9;1380:23;1422:18;1463:2;1455:6;1452:14;1449:34;;;1479:1;1476;1469:12;1449:34;1518:58;1568:7;1559:6;1548:9;1544:22;1518:58;:::i;:::-;1595:8;;-1:-1:-1;1492:84:1;-1:-1:-1;1683:2:1;1668:18;;1655:32;;-1:-1:-1;1699:16:1;;;1696:36;;;1728:1;1725;1718:12;1696:36;;1767:72;1831:7;1820:8;1809:9;1805:24;1767:72;:::i;:::-;1154:745;;;;-1:-1:-1;1858:8:1;-1:-1:-1;;;;1154:745:1:o;2096:154::-;2182:42;2175:5;2171:54;2164:5;2161:65;2151:93;;2240:1;2237;2230:12;2255:247;2314:6;2367:2;2355:9;2346:7;2342:23;2338:32;2335:52;;;2383:1;2380;2373:12;2335:52;2422:9;2409:23;2441:31;2466:5;2441:31;:::i;2507:813::-;2622:6;2630;2638;2646;2654;2707:2;2695:9;2686:7;2682:23;2678:32;2675:52;;;2723:1;2720;2713:12;2675:52;2759:9;2746:23;2736:33;;2820:2;2809:9;2805:18;2792:32;2843:18;2884:2;2876:6;2873:14;2870:34;;;2900:1;2897;2890:12;2870:34;2939:58;2989:7;2980:6;2969:9;2965:22;2939:58;:::i;:::-;3016:8;;-1:-1:-1;2913:84:1;-1:-1:-1;3104:2:1;3089:18;;3076:32;;-1:-1:-1;3120:16:1;;;3117:36;;;3149:1;3146;3139:12;3117:36;;3188:72;3252:7;3241:8;3230:9;3226:24;3188:72;:::i;:::-;2507:813;;;;-1:-1:-1;2507:813:1;;-1:-1:-1;3279:8:1;;3162:98;2507:813;-1:-1:-1;;;2507:813:1:o;3325:1018::-;3458:6;3466;3474;3482;3490;3498;3506;3559:3;3547:9;3538:7;3534:23;3530:33;3527:53;;;3576:1;3573;3566:12;3527:53;3612:9;3599:23;3589:33;;3672:2;3661:9;3657:18;3644:32;3685:31;3710:5;3685:31;:::i;:::-;3735:5;-1:-1:-1;3791:2:1;3776:18;;3763:32;3814:18;3844:14;;;3841:34;;;3871:1;3868;3861:12;3841:34;3910:70;3972:7;3963:6;3952:9;3948:22;3910:70;:::i;:::-;3999:8;;-1:-1:-1;3884:96:1;-1:-1:-1;4087:2:1;4072:18;;4059:32;;-1:-1:-1;4103:16:1;;;4100:36;;;4132:1;4129;4122:12;4100:36;;4171:60;4223:7;4212:8;4201:9;4197:24;4171:60;:::i;:::-;3325:1018;;;;-1:-1:-1;3325:1018:1;;;;;;4332:3;4317:19;;;4304:33;;3325:1018;-1:-1:-1;;;;3325:1018:1:o;4530:184::-;4582:77;4579:1;4572:88;4679:4;4676:1;4669:15;4703:4;4700:1;4693:15;4719:255;4791:2;4785:9;4833:6;4821:19;;4870:18;4855:34;;4891:22;;;4852:62;4849:88;;;4917:18;;:::i;:::-;4953:2;4946:22;4719:255;:::o;4979:334::-;5050:2;5044:9;5106:2;5096:13;;-1:-1:-1;;5092:86:1;5080:99;;5209:18;5194:34;;5230:22;;;5191:62;5188:88;;;5256:18;;:::i;:::-;5292:2;5285:22;4979:334;;-1:-1:-1;4979:334:1:o;5318:129::-;5403:18;5396:5;5392:30;5385:5;5382:41;5372:69;;5437:1;5434;5427:12;5452:132;5519:20;;5548:30;5519:20;5548:30;:::i;5589:245::-;5637:4;5670:18;5662:6;5659:30;5656:56;;;5692:18;;:::i;:::-;-1:-1:-1;5749:2:1;5737:15;-1:-1:-1;;5733:88:1;5823:4;5729:99;;5589:245::o;5839:462::-;5881:5;5934:3;5927:4;5919:6;5915:17;5911:27;5901:55;;5952:1;5949;5942:12;5901:55;5988:6;5975:20;6019:48;6035:31;6063:2;6035:31;:::i;:::-;6019:48;:::i;:::-;6092:2;6083:7;6076:19;6138:3;6131:4;6126:2;6118:6;6114:15;6110:26;6107:35;6104:55;;;6155:1;6152;6145:12;6104:55;6220:2;6213:4;6205:6;6201:17;6194:4;6185:7;6181:18;6168:55;6268:1;6243:16;;;6261:4;6239:27;6232:38;;;;6247:7;5839:462;-1:-1:-1;;;5839:462:1:o;6306:1156::-;6403:6;6456:2;6444:9;6435:7;6431:23;6427:32;6424:52;;;6472:1;6469;6462:12;6424:52;6512:9;6499:23;6541:18;6582:2;6574:6;6571:14;6568:34;;;6598:1;6595;6588:12;6568:34;6621:22;;;;6677:6;6659:16;;;6655:29;6652:49;;;6697:1;6694;6687:12;6652:49;6723:22;;:::i;:::-;6781:2;6768:16;6761:5;6754:31;6838:2;6834;6830:11;6817:25;6812:2;6805:5;6801:14;6794:49;6896:2;6892;6888:11;6875:25;6870:2;6863:5;6859:14;6852:49;6954:2;6950;6946:11;6933:25;6928:2;6921:5;6917:14;6910:49;7013:3;7009:2;7005:12;6992:26;6986:3;6979:5;6975:15;6968:51;7052:31;7078:3;7074:2;7070:12;7052:31;:::i;:::-;7046:3;7039:5;7035:15;7028:56;7130:3;7126:2;7122:12;7109:26;7160:2;7150:8;7147:16;7144:36;;;7176:1;7173;7166:12;7144:36;7213:44;7249:7;7238:8;7234:2;7230:17;7213:44;:::i;:::-;7207:3;7200:5;7196:15;7189:69;;7304:3;7300:2;7296:12;7283:26;7334:2;7324:8;7321:16;7318:36;;;7350:1;7347;7340:12;7318:36;7387:44;7423:7;7412:8;7408:2;7404:17;7387:44;:::i;:::-;7381:3;7370:15;;7363:69;-1:-1:-1;7374:5:1;6306:1156;-1:-1:-1;;;;;6306:1156:1:o;7467:250::-;7552:1;7562:113;7576:6;7573:1;7570:13;7562:113;;;7652:11;;;7646:18;7633:11;;;7626:39;7598:2;7591:10;7562:113;;;-1:-1:-1;;7709:1:1;7691:16;;7684:27;7467:250::o;7722:329::-;7763:3;7801:5;7795:12;7828:6;7823:3;7816:19;7844:76;7913:6;7906:4;7901:3;7897:14;7890:4;7883:5;7879:16;7844:76;:::i;:::-;7965:2;7953:15;-1:-1:-1;;7949:88:1;7940:98;;;;8040:4;7936:109;;7722:329;-1:-1:-1;;7722:329:1:o;8056:217::-;8203:2;8192:9;8185:21;8166:4;8223:44;8263:2;8252:9;8248:18;8240:6;8223:44;:::i;8278:1379::-;8431:6;8439;8447;8455;8463;8471;8479;8487;8495;8548:3;8536:9;8527:7;8523:23;8519:33;8516:53;;;8565:1;8562;8555:12;8516:53;8601:9;8588:23;8578:33;;8661:2;8650:9;8646:18;8633:32;8674:31;8699:5;8674:31;:::i;:::-;8724:5;-1:-1:-1;8781:2:1;8766:18;;8753:32;8794:33;8753:32;8794:33;:::i;:::-;8846:7;-1:-1:-1;8904:2:1;8889:18;;8876:32;8927:18;8957:14;;;8954:34;;;8984:1;8981;8974:12;8954:34;9023:70;9085:7;9076:6;9065:9;9061:22;9023:70;:::i;:::-;9112:8;;-1:-1:-1;8997:96:1;-1:-1:-1;9200:3:1;9185:19;;9172:33;;-1:-1:-1;9217:16:1;;;9214:36;;;9246:1;9243;9236:12;9214:36;9285:60;9337:7;9326:8;9315:9;9311:24;9285:60;:::i;:::-;9364:8;;-1:-1:-1;9259:86:1;-1:-1:-1;9452:3:1;9437:19;;9424:33;;-1:-1:-1;9469:16:1;;;9466:36;;;9498:1;9495;9488:12;9466:36;;9537:60;9589:7;9578:8;9567:9;9563:24;9537:60;:::i;:::-;9511:86;;9616:8;9606:18;;;9643:8;9633:18;;;8278:1379;;;;;;;;;;;:::o;10541:1306::-;10694:6;10702;10710;10718;10726;10734;10742;10750;10758;10811:3;10799:9;10790:7;10786:23;10782:33;10779:53;;;10828:1;10825;10818:12;10779:53;10864:9;10851:23;10841:33;;10921:2;10910:9;10906:18;10893:32;10883:42;;10975:2;10964:9;10960:18;10947:32;10988:31;11013:5;10988:31;:::i;12034:320::-;12102:6;12155:2;12143:9;12134:7;12130:23;12126:32;12123:52;;;12171:1;12168;12161:12;12123:52;12211:9;12198:23;12244:18;12236:6;12233:30;12230:50;;;12276:1;12273;12266:12;12230:50;12299:49;12340:7;12331:6;12320:9;12316:22;12299:49;:::i;12663:248::-;12731:6;12739;12792:2;12780:9;12771:7;12767:23;12763:32;12760:52;;;12808:1;12805;12798:12;12760:52;-1:-1:-1;;12831:23:1;;;12901:2;12886:18;;;12873:32;;-1:-1:-1;12663:248:1:o;12916:409::-;12986:6;12994;13047:2;13035:9;13026:7;13022:23;13018:32;13015:52;;;13063:1;13060;13053:12;13015:52;13103:9;13090:23;13136:18;13128:6;13125:30;13122:50;;;13168:1;13165;13158:12;13122:50;13207:58;13257:7;13248:6;13237:9;13233:22;13207:58;:::i;:::-;13284:8;;13181:84;;-1:-1:-1;12916:409:1;-1:-1:-1;;;;12916:409:1:o;13583:527::-;13840:6;13829:9;13822:25;13883:6;13878:2;13867:9;13863:18;13856:34;13926:6;13921:2;13910:9;13906:18;13899:34;13981:18;13973:6;13969:31;13964:2;13953:9;13949:18;13942:59;14038:3;14032;14021:9;14017:19;14010:32;13803:4;14059:45;14099:3;14088:9;14084:19;14076:6;14059:45;:::i;14439:545::-;14539:6;14534:3;14527:19;14509:3;14565:4;14594:2;14589:3;14585:12;14578:19;;14620:5;14643:1;14653:306;14667:6;14664:1;14661:13;14653:306;;;14744:6;14731:20;14764:33;14789:7;14764:33;:::i;:::-;14835:42;14822:56;14810:69;;14899:12;;;;14934:15;;;;14689:1;14682:9;14653:306;;;-1:-1:-1;14975:3:1;;14439:545;-1:-1:-1;;;;;14439:545:1:o;14989:359::-;15206:6;15195:9;15188:25;15249:2;15244;15233:9;15229:18;15222:30;15169:4;15269:73;15338:2;15327:9;15323:18;15315:6;15307;15269:73;:::i;:::-;15261:81;14989:359;-1:-1:-1;;;;;14989:359:1:o;15353:184::-;15423:6;15476:2;15464:9;15455:7;15451:23;15447:32;15444:52;;;15492:1;15489;15482:12;15444:52;-1:-1:-1;15515:16:1;;15353:184;-1:-1:-1;15353:184:1:o;15542:325::-;15630:6;15625:3;15618:19;15682:6;15675:5;15668:4;15663:3;15659:14;15646:43;;15734:1;15727:4;15718:6;15713:3;15709:16;15705:27;15698:38;15600:3;15856:4;-1:-1:-1;;15781:2:1;15773:6;15769:15;15765:88;15760:3;15756:98;15752:109;15745:116;;15542:325;;;;:::o;15872:386::-;16085:6;16074:9;16067:25;16128:6;16123:2;16112:9;16108:18;16101:34;16171:2;16166;16155:9;16151:18;16144:30;16048:4;16191:61;16248:2;16237:9;16233:18;16225:6;16217;16191:61;:::i;:::-;16183:69;15872:386;-1:-1:-1;;;;;;15872:386:1:o;16263:184::-;16315:77;16312:1;16305:88;16412:4;16409:1;16402:15;16436:4;16433:1;16426:15;16452:125;16517:9;;;16538:10;;;16535:36;;;16551:18;;:::i;16884:136::-;16962:13;;16984:30;16962:13;16984:30;:::i;17025:310::-;17103:6;17111;17164:2;17152:9;17143:7;17139:23;17135:32;17132:52;;;17180:1;17177;17170:12;17132:52;17209:9;17203:16;17193:26;;17262:2;17251:9;17247:18;17241:25;17275:30;17299:5;17275:30;:::i;:::-;17324:5;17314:15;;;17025:310;;;;;:::o;17593:441::-;17646:5;17699:3;17692:4;17684:6;17680:17;17676:27;17666:55;;17717:1;17714;17707:12;17666:55;17746:6;17740:13;17777:48;17793:31;17821:2;17793:31;:::i;17777:48::-;17850:2;17841:7;17834:19;17896:3;17889:4;17884:2;17876:6;17872:15;17868:26;17865:35;17862:55;;;17913:1;17910;17903:12;17862:55;17926:77;18000:2;17993:4;17984:7;17980:18;17973:4;17965:6;17961:17;17926:77;:::i;18039:1144::-;18147:6;18200:2;18188:9;18179:7;18175:23;18171:32;18168:52;;;18216:1;18213;18206:12;18168:52;18249:9;18243:16;18278:18;18319:2;18311:6;18308:14;18305:34;;;18335:1;18332;18325:12;18305:34;18358:22;;;;18414:6;18396:16;;;18392:29;18389:49;;;18434:1;18431;18424:12;18389:49;18460:22;;:::i;:::-;18511:2;18505:9;18498:5;18491:24;18561:2;18557;18553:11;18547:18;18542:2;18535:5;18531:14;18524:42;18612:2;18608;18604:11;18598:18;18593:2;18586:5;18582:14;18575:42;18663:2;18659;18655:11;18649:18;18644:2;18637:5;18633:14;18626:42;18715:3;18711:2;18707:12;18701:19;18695:3;18688:5;18684:15;18677:44;18754:42;18791:3;18787:2;18783:12;18754:42;:::i;:::-;18748:3;18741:5;18737:15;18730:67;18836:3;18832:2;18828:12;18822:19;18866:2;18856:8;18853:16;18850:36;;;18882:1;18879;18872:12;18850:36;18919:55;18966:7;18955:8;18951:2;18947:17;18919:55;:::i;:::-;18913:3;18906:5;18902:15;18895:80;;19014:3;19010:2;19006:12;19000:19;19044:2;19034:8;19031:16;19028:36;;;19060:1;19057;19050:12;19028:36;19097:55;19144:7;19133:8;19129:2;19125:17;19097:55;:::i;19377:475::-;19444:5;19492:4;19480:9;19475:3;19471:19;19467:30;19464:50;;;19510:1;19507;19500:12;19464:50;19543:4;19537:11;19587:4;19579:6;19575:17;19658:6;19646:10;19643:22;19622:18;19610:10;19607:34;19604:62;19601:88;;;19669:18;;:::i;:::-;19705:4;19698:24;19770:16;;19755:32;;19841:2;19826:18;;;19820:25;19803:15;;;19796:50;;;;-1:-1:-1;19740:6:1;19377:475;-1:-1:-1;19377:475:1:o;19857:252::-;19953:6;20006:2;19994:9;19985:7;19981:23;19977:32;19974:52;;;20022:1;20019;20012:12;19974:52;20045:58;20095:7;20084:9;20045:58;:::i;20114:1213::-;20227:6;20235;20288:2;20276:9;20267:7;20263:23;20259:32;20256:52;;;20304:1;20301;20294:12;20256:52;20337:9;20331:16;20366:18;20407:2;20399:6;20396:14;20393:34;;;20423:1;20420;20413:12;20393:34;20446:60;20498:7;20489:6;20478:9;20474:22;20446:60;:::i;:::-;20436:70;;20525:2;20515:12;;20573:2;20562:9;20558:18;20552:25;20602:2;20592:8;20589:16;20586:36;;;20618:1;20615;20608:12;20586:36;20641:24;;20696:4;20688:13;;20684:27;-1:-1:-1;20674:55:1;;20725:1;20722;20715:12;20674:55;20754:2;20748:9;20776:2;20772;20769:10;20766:36;;;20782:18;;:::i;:::-;20828:2;20825:1;20821:10;20811:20;;20851:28;20875:2;20871;20867:11;20851:28;:::i;:::-;20913:15;;;20983:11;;;20979:20;;;20944:12;;;;21011:19;;;21008:39;;;21043:1;21040;21033:12;21008:39;21067:11;;;;21087:210;21103:6;21098:3;21095:15;21087:210;;;21176:3;21170:10;21157:23;;21193:31;21218:5;21193:31;:::i;:::-;21237:18;;;21120:12;;;;21275;;;;21087:210;;;21316:5;21306:15;;;;;;;;20114:1213;;;;;:::o;21332:1023::-;21537:2;21526:9;21519:21;21582:6;21576:13;21571:2;21560:9;21556:18;21549:41;21644:2;21636:6;21632:15;21626:22;21621:2;21610:9;21606:18;21599:50;21703:2;21695:6;21691:15;21685:22;21680:2;21669:9;21665:18;21658:50;21763:2;21755:6;21751:15;21745:22;21739:3;21728:9;21724:19;21717:51;21823:3;21815:6;21811:16;21805:23;21799:3;21788:9;21784:19;21777:52;21895:18;21888:3;21880:6;21876:16;21870:23;21866:48;21860:3;21849:9;21845:19;21838:77;21500:4;21962:3;21954:6;21950:16;21944:23;21986:6;22029:2;22023:3;22012:9;22008:19;22001:31;22055:51;22101:3;22090:9;22086:19;22072:12;22055:51;:::i;:::-;22041:65;;22155:3;22147:6;22143:16;22137:23;-1:-1:-1;;22212:9:1;22204:6;22200:22;22196:95;22191:2;22180:9;22176:18;22169:123;22309:40;22342:6;22326:14;22309:40;:::i;22360:430::-;22605:6;22594:9;22587:25;22648:6;22643:2;22632:9;22628:18;22621:34;22691:2;22686;22675:9;22671:18;22664:30;22568:4;22711:73;22780:2;22769:9;22765:18;22757:6;22749;22711:73;:::i;22795:184::-;22847:77;22844:1;22837:88;22944:4;22941:1;22934:15;22968:4;22965:1;22958:15;22984:531;23253:6;23242:9;23235:25;23296:6;23291:2;23280:9;23276:18;23269:34;23339:6;23334:2;23323:9;23319:18;23312:34;23382:6;23377:2;23366:9;23362:18;23355:34;23426:3;23420;23409:9;23405:19;23398:32;23216:4;23447:62;23504:3;23493:9;23489:19;23481:6;23473;23447:62;:::i;:::-;23439:70;22984:531;-1:-1:-1;;;;;;;;22984:531:1:o;23520:251::-;23590:6;23643:2;23631:9;23622:7;23618:23;23614:32;23611:52;;;23659:1;23656;23649:12;23611:52;23691:9;23685:16;23710:31;23735:5;23710:31;:::i;24149:737::-;24482:6;24471:9;24464:25;24525:6;24520:2;24509:9;24505:18;24498:34;24568:6;24563:2;24552:9;24548:18;24541:34;24611:6;24606:2;24595:9;24591:18;24584:34;24655:6;24649:3;24638:9;24634:19;24627:35;24699:3;24693;24682:9;24678:19;24671:32;24445:4;24726:45;24766:3;24755:9;24751:19;24743:6;24726:45;:::i;:::-;24820:9;24812:6;24808:22;24802:3;24791:9;24787:19;24780:51;24848:32;24873:6;24865;24848:32;:::i;24891:485::-;24977:6;24985;25038:2;25026:9;25017:7;25013:23;25009:32;25006:52;;;25054:1;25051;25044:12;25006:52;25086:9;25080:16;25136:4;25129:5;25125:16;25118:5;25115:27;25105:55;;25156:1;25153;25146:12;25105:55;25228:2;25213:18;;25207:25;25179:5;;-1:-1:-1;25255:18:1;25244:30;;25241:50;;;25287:1;25284;25277:12;25241:50;25310:60;25362:7;25353:6;25342:9;25338:22;25310:60;:::i;:::-;25300:70;;;24891:485;;;;;:::o;25640:184::-;25692:77;25689:1;25682:88;25789:4;25786:1;25779:15;25813:4;25810:1;25803:15;25829:1041;26150:42;26142:6;26138:55;26127:9;26120:74;26236:6;26230:13;26225:2;26214:9;26210:18;26203:41;26298:2;26290:6;26286:15;26280:22;26275:2;26264:9;26260:18;26253:50;26367:18;26361:2;26353:6;26349:15;26343:22;26339:47;26334:2;26323:9;26319:18;26312:75;26442:2;26434:6;26430:15;26424:22;26418:3;26407:9;26403:19;26396:51;26502:3;26494:6;26490:16;26484:23;26478:3;26467:9;26463:19;26456:52;26545:3;26539;26528:9;26524:19;26517:32;26586:6;26580:3;26569:9;26565:19;26558:35;26101:4;26612:3;26638:66;26630:6;26627:78;26624:98;;;26718:1;26715;26708:12;26624:98;26752:6;26749:1;26745:14;26809:6;26801;26796:2;26785:9;26781:18;26768:48;26837:22;;;;26833:31;;;;25829:1041;-1:-1:-1;;;;;25829:1041:1:o;26875:195::-;26914:3;26945:66;26938:5;26935:77;26932:103;;27015:18;;:::i;:::-;-1:-1:-1;27062:1:1;27051:13;;26875:195::o","abiDefinition":[{"inputs":[{"internalType":"address","name":"interchainDB","type":"address"},{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"AppConfigLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__FeeAmountTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__IncorrectDstChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__IncorrectMsgValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NoLinkedClient","type":"error"},{"inputs":[{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"InterchainClientV1__NotEVMClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__NotEnoughResponses","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NotRemoteChainId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxAlreadyExecuted","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxNotExecuted","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroReceiver","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroRequiredResponses","type":"error"},{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionFees","type":"address"}],"name":"ExecutionFeesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"address","name":"executor","type":"address"}],"name":"ExecutionProofWritten","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"}],"name":"InterchainTransactionReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"dstChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"verificationFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"options","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"InterchainTransactionSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"LinkedClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"INTERCHAIN_DB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedOptions","type":"bytes"}],"name":"decodeOptions","outputs":[{"components":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"}],"internalType":"struct OptionsV1","name":"","type":"tuple"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"dstReceiver","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct InterchainTransaction","name":"icTx","type":"tuple"}],"name":"encodeTransaction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"executionFees","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedTx","type":"bytes"}],"name":"getExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getExecutorById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"uint256","name":"messageLen","type":"uint256"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClient","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClientEVM","outputs":[{"internalType":"address","name":"linkedClientEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"interchainExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSend","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSendEVM","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedTx","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"isExecutable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionFees_","type":"address"}],"name":"setExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"setLinkedClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"writeExecutionProof","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"INTERCHAIN_DB()":{"notice":"Address of the InterchainDB contract, set at the time of deployment."},"decodeOptions(bytes)":{"notice":"Decodes the encoded options data into a OptionsV1 struct."},"encodeTransaction((uint256,bytes32,uint256,bytes32,uint256,uint64,bytes,bytes))":{"notice":"Encodes the transaction data into a bytes format."},"executionFees()":{"notice":"Address of the contract that handles execution fees. Can be updated by the owner."},"getExecutorById(bytes32)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getInterchainFee(uint256,address,address[],bytes,uint256)":{"notice":"Returns the fee for sending an Interchain message."},"getLinkedClient(uint256)":{"notice":"Returns the address of the linked client (as bytes32) for a specific chain ID."},"getLinkedClientEVM(uint256)":{"notice":"Returns the EVM address of the linked client for a specific chain ID."},"interchainExecute(uint256,bytes,bytes32[])":{"notice":"Executes a transaction that has been sent via the Interchain."},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"notice":"Sends a message to another chain via the Interchain Communication Protocol."},"setExecutionFees(address)":{"notice":"Sets the address of the ExecutionFees contract."},"setLinkedClient(uint256,bytes32)":{"notice":"Sets the linked client for a specific chain ID."},"writeExecutionProof(bytes32)":{"notice":"Writes the proof of execution for a transaction into the InterchainDB."}},"version":1},"developerDoc":{"details":"Implements the operations of the Interchain Execution Layer.","errors":{"OwnableInvalidOwner(address)":[{"details":"The owner is not a valid owner account. (eg. `address(0)`)"}],"OwnableUnauthorizedAccount(address)":[{"details":"The caller account is not authorized to perform an operation."}]},"kind":"dev","methods":{"getInterchainFee(uint256,address,address[],bytes,uint256)":{"params":{"dstChainId":"The chain ID of the destination chain.","messageLen":"The length of the message being sent.","options":"Execution options for the message sent, currently gas limit + native gas drop.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."}},"getLinkedClient(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID."},"getLinkedClientEVM(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client."},"interchainExecute(uint256,bytes,bytes32[])":{"details":"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.","params":{"gasLimit":"The gas limit to use for the execution.","proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The transaction data."}},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"details":"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.","params":{"dstChainId":"The chain ID of the destination chain.","message":"The message being sent.","options":"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.","receiver":"The address of the receiver on the destination chain.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."},"returns":{"desc":"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch."}},"owner()":{"details":"Returns the address of the current owner."},"renounceOwnership()":{"details":"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner."},"setExecutionFees(address)":{"details":"Only callable by the contract owner or an authorized account.","params":{"executionFees_":"The address of the ExecutionFees contract."}},"setLinkedClient(uint256,bytes32)":{"details":"Stores the address of the linked client in a mapping with the chain ID as the key.","params":{"chainId":"The chain ID for which the client is being set.","client":"The address of the client being linked."}},"transferOwnership(address)":{"details":"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."},"writeExecutionProof(bytes32)":{"details":"Will revert if the transaction has not been executed.","params":{"transactionId":"The ID of the transaction to write the proof for."},"returns":{"dbNonce":" The database nonce of the batch containing the written proof for transaction.","entryIndex":" The index of the written proof for transaction within the batch."}}},"stateVariables":{"_linkedClient":{"details":"Address of the InterchainClient contract on the remote chain"},"_txExecutor":{"details":"Executor address that completed the transaction. Address(0) if not executed yet."}},"title":"InterchainClientV1","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"interchainDB\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionFees\",\"type\":\"address\"}],\"name\":\"ExecutionFeesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionProofWritten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"}],\"name\":\"InterchainTransactionReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"verificationFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"InterchainTransactionSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"LinkedClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"INTERCHAIN_DB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedOptions\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"struct OptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"struct InterchainTransaction\",\"name\":\"icTx\",\"type\":\"tuple\"}],\"name\":\"encodeTransaction\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executionFees\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedClientEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implements the operations of the Interchain Execution Layer.\",\"errors\":{\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}]},\"kind\":\"dev\",\"methods\":{\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"messageLen\":\"The length of the message being sent.\",\"options\":\"Execution options for the message sent, currently gas limit + native gas drop.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"}},\"getLinkedClient(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"details\":\"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.\",\"params\":{\"gasLimit\":\"The gas limit to use for the execution.\",\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The transaction data.\"}},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"details\":\"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.\",\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"message\":\"The message being sent.\",\"options\":\"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\",\"receiver\":\"The address of the receiver on the destination chain.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"},\"returns\":{\"desc\":\"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"setExecutionFees(address)\":{\"details\":\"Only callable by the contract owner or an authorized account.\",\"params\":{\"executionFees_\":\"The address of the ExecutionFees contract.\"}},\"setLinkedClient(uint256,bytes32)\":{\"details\":\"Stores the address of the linked client in a mapping with the chain ID as the key.\",\"params\":{\"chainId\":\"The chain ID for which the client is being set.\",\"client\":\"The address of the client being linked.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"writeExecutionProof(bytes32)\":{\"details\":\"Will revert if the transaction has not been executed.\",\"params\":{\"transactionId\":\"The ID of the transaction to write the proof for.\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written proof for transaction.\",\"entryIndex\":\" The index of the written proof for transaction within the batch.\"}}},\"stateVariables\":{\"_linkedClient\":{\"details\":\"Address of the InterchainClient contract on the remote chain\"},\"_txExecutor\":{\"details\":\"Executor address that completed the transaction. Address(0) if not executed yet.\"}},\"title\":\"InterchainClientV1\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"INTERCHAIN_DB()\":{\"notice\":\"Address of the InterchainDB contract, set at the time of deployment.\"},\"decodeOptions(bytes)\":{\"notice\":\"Decodes the encoded options data into a OptionsV1 struct.\"},\"encodeTransaction((uint256,bytes32,uint256,bytes32,uint256,uint64,bytes,bytes))\":{\"notice\":\"Encodes the transaction data into a bytes format.\"},\"executionFees()\":{\"notice\":\"Address of the contract that handles execution fees. Can be updated by the owner.\"},\"getExecutorById(bytes32)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"notice\":\"Returns the fee for sending an Interchain message.\"},\"getLinkedClient(uint256)\":{\"notice\":\"Returns the address of the linked client (as bytes32) for a specific chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"notice\":\"Returns the EVM address of the linked client for a specific chain ID.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"notice\":\"Executes a transaction that has been sent via the Interchain.\"},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"notice\":\"Sends a message to another chain via the Interchain Communication Protocol.\"},\"setExecutionFees(address)\":{\"notice\":\"Sets the address of the ExecutionFees contract.\"},\"setLinkedClient(uint256,bytes32)\":{\"notice\":\"Sets the linked client for a specific chain ID.\"},\"writeExecutionProof(bytes32)\":{\"notice\":\"Writes the proof of execution for a transaction into the InterchainDB.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainClientV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"INTERCHAIN_DB()":"e4c61247","decodeOptions(bytes)":"d5e788a0","encodeTransaction((uint256,bytes32,uint256,bytes32,uint256,uint64,bytes,bytes))":"7c80a90f","executionFees()":"7341eaf9","getExecutor(bytes)":"f92a79ff","getExecutorById(bytes32)":"f1a61fac","getInterchainFee(uint256,address,address[],bytes,uint256)":"7a1277db","getLinkedClient(uint256)":"aa102ec4","getLinkedClientEVM(uint256)":"02172a35","interchainExecute(uint256,bytes,bytes32[])":"53b67d74","interchainSend(uint256,bytes32,address,address[],bytes,bytes)":"98939d28","interchainSendEVM(uint256,address,address,address[],bytes,bytes)":"827f940d","isExecutable(bytes,bytes32[])":"1450c281","owner()":"8da5cb5b","renounceOwnership()":"715018a6","setExecutionFees(address)":"3dc68b87","setLinkedClient(uint256,bytes32)":"f34234c8","transferOwnership(address)":"f2fde38b","writeExecutionProof(bytes32)":"90e81077"}},"solidity/InterchainClientV1.sol:InterchainClientV1Events":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionFees","type":"address"}],"name":"ExecutionFeesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"address","name":"executor","type":"address"}],"name":"ExecutionProofWritten","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"}],"name":"InterchainTransactionReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"dstChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"verificationFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"options","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"InterchainTransactionSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"LinkedClientSet","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionFees\",\"type\":\"address\"}],\"name\":\"ExecutionFeesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionProofWritten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"}],\"name\":\"InterchainTransactionReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"verificationFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"InterchainTransactionSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"LinkedClientSet\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainClientV1Events\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:InterchainEntryLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fa75986447d941d0d0d82ad406b35fa5eff33cb456ed04814bfba416f17295c664736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220fa75986447d941d0d0d82ad406b35fa5eff33cb456ed04814bfba416f17295c664736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"16901:1633:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;16901:1633:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"16901:1633:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainEntryLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:InterchainTransactionLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122027fd9eaf7fbfbf97c5d523cd33263b7a545d831c13c1bfcb6027b3c292bb264464736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122027fd9eaf7fbfbf97c5d523cd33263b7a545d831c13c1bfcb6027b3c292bb264464736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"22023:1773:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;22023:1773:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"22023:1773:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainTransactionLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:MathLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207406f0a7a44da8114195fc16d740573c3f89e6362549fba952d0054ad35b9e3b64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207406f0a7a44da8114195fc16d740573c3f89e6362549fba952d0054ad35b9e3b64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"11913:403:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;11913:403:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"11913:403:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"MathLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220606469f7a1c621594699c1cb221f4c081709b7c7fd4e931cf5c119c428f1d37664736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220606469f7a1c621594699c1cb221f4c081709b7c7fd4e931cf5c119c428f1d37664736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"12835:1958:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;12835:1958:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"12835:1958:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:Ownable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. The initial owner is set to the address provided by the deployer. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.","errors":{"OwnableInvalidOwner(address)":[{"details":"The owner is not a valid owner account. (eg. `address(0)`)"}],"OwnableUnauthorizedAccount(address)":[{"details":"The caller account is not authorized to perform an operation."}]},"kind":"dev","methods":{"constructor":{"details":"Initializes the contract setting the address provided by the deployer as the initial owner."},"owner()":{"details":"Returns the address of the current owner."},"renounceOwnership()":{"details":"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner."},"transferOwnership(address)":{"details":"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. The initial owner is set to the address provided by the deployer. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.\",\"errors\":{\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}]},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Initializes the contract setting the address provided by the deployer as the initial owner.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"Ownable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{"owner()":"8da5cb5b","renounceOwnership()":"715018a6","transferOwnership(address)":"f2fde38b"}},"solidity/InterchainClientV1.sol:TypeCasts":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220282b529922d3a9d3f383e64bca7954adc896448545468d8ce7cc2b9aefc9749064736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220282b529922d3a9d3f383e64bca7954adc896448545468d8ce7cc2b9aefc9749064736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external pure returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"14828:280:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;14828:280:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"14828:280:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"TypeCasts\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0xf0ac1413ab92ddee5de4d1b95cc89e50d324dfb89c823cf95cce289499e1a793\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4128bd9b9660633f22e24f4f7e03b51b21e2898baf372506ae7faa2423cbb762\",\"dweb:/ipfs/QmcKz8Dm11W78ykSJnicZK9Aixe7wPCkaRpqiPA5TzEamP\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file +{"solidity/InterchainClientV1.sol:AppConfigLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122012d05505a05b58970134f05a99b51c118a09086c491bbfb5706f3ae8d93f6fa764736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122012d05505a05b58970134f05a99b51c118a09086c491bbfb5706f3ae8d93f6fa764736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"15389:1275:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;15389:1275:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"15389:1275:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"AppConfigLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"AppConfigLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:Context":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"Context\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:IExecutionFees":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address","name":"executor","type":"address"}],"name":"ExecutionFees__AlreadyRecorded","type":"error"},{"inputs":[],"name":"ExecutionFees__ZeroAddress","type":"error"},{"inputs":[],"name":"ExecutionFees__ZeroAmount","type":"error"},{"inputs":[{"internalType":"address","name":"executor","type":"address"}],"name":"accumulatedRewards","outputs":[{"internalType":"uint256","name":"accumulated","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"addExecutionFee","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"executor","type":"address"}],"name":"claimExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"executionFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"address","name":"executor","type":"address"}],"name":"recordExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"recordedExecutor","outputs":[{"internalType":"address","name":"executor","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"executor","type":"address"}],"name":"unclaimedRewards","outputs":[{"internalType":"uint256","name":"unclaimed","type":"uint256"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"accumulatedRewards(address)":{"notice":"Get the accumulated rewards for an executor."},"addExecutionFee(uint256,bytes32)":{"notice":"Add the execution fee for a transaction. The attached value will be added to the rewards for the executor completing the transaction. Note: this could be used to store the execution fee for a new transaction, or to add more funds to the execution fee of an existing transaction. Therefore this function is payable, and does not implement any caller restrictions."},"claimExecutionFees(address)":{"notice":"Allows the executor to claim their unclaimed rewards."},"executionFee(uint256,bytes32)":{"notice":"Get the total execution fee for a transaction."},"recordExecutor(uint256,bytes32,address)":{"notice":"Record the executor (who completed the transaction) for a transaction, and update the accumulated rewards for the executor."},"recordedExecutor(uint256,bytes32)":{"notice":"Get the address of the recorded executor for a transaction."},"unclaimedRewards(address)":{"notice":"Get the unclaimed rewards for an executor."}},"version":1},"developerDoc":{"kind":"dev","methods":{"accumulatedRewards(address)":{"params":{"executor":"The address of the executor to get the rewards for."}},"addExecutionFee(uint256,bytes32)":{"details":"Will revert if the executor is already recorded for the transaction.","params":{"dstChainId":"The chain id of the destination chain.","transactionId":"The id of the transaction to add the execution fee to."}},"claimExecutionFees(address)":{"details":"Will revert if the executor has no unclaimed rewards."},"executionFee(uint256,bytes32)":{"params":{"dstChainId":"The chain id of the destination chain.","transactionId":"The id of the transaction to get the execution fee for."}},"recordExecutor(uint256,bytes32,address)":{"details":"Could only be called by the Recorder.","params":{"dstChainId":"The chain id of the destination chain.","executor":"The address of the executor who completed the transaction.","transactionId":"The id of the transaction to record the executor for."}},"recordedExecutor(uint256,bytes32)":{"details":"Will return address(0) if the executor is not recorded.","params":{"dstChainId":"The chain id of the destination chain.","transactionId":"The id of the transaction to get the recorded executor for."}},"unclaimedRewards(address)":{"params":{"executor":"The address of the executor to get the rewards for."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionFees__AlreadyRecorded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ExecutionFees__ZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ExecutionFees__ZeroAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"accumulatedRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"accumulated\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"addExecutionFee\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"claimExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"executionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"recordExecutor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"recordedExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"unclaimedRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"unclaimed\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"accumulatedRewards(address)\":{\"params\":{\"executor\":\"The address of the executor to get the rewards for.\"}},\"addExecutionFee(uint256,bytes32)\":{\"details\":\"Will revert if the executor is already recorded for the transaction.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"transactionId\":\"The id of the transaction to add the execution fee to.\"}},\"claimExecutionFees(address)\":{\"details\":\"Will revert if the executor has no unclaimed rewards.\"},\"executionFee(uint256,bytes32)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"transactionId\":\"The id of the transaction to get the execution fee for.\"}},\"recordExecutor(uint256,bytes32,address)\":{\"details\":\"Could only be called by the Recorder.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executor\":\"The address of the executor who completed the transaction.\",\"transactionId\":\"The id of the transaction to record the executor for.\"}},\"recordedExecutor(uint256,bytes32)\":{\"details\":\"Will return address(0) if the executor is not recorded.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"transactionId\":\"The id of the transaction to get the recorded executor for.\"}},\"unclaimedRewards(address)\":{\"params\":{\"executor\":\"The address of the executor to get the rewards for.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"accumulatedRewards(address)\":{\"notice\":\"Get the accumulated rewards for an executor.\"},\"addExecutionFee(uint256,bytes32)\":{\"notice\":\"Add the execution fee for a transaction. The attached value will be added to the rewards for the executor completing the transaction. Note: this could be used to store the execution fee for a new transaction, or to add more funds to the execution fee of an existing transaction. Therefore this function is payable, and does not implement any caller restrictions.\"},\"claimExecutionFees(address)\":{\"notice\":\"Allows the executor to claim their unclaimed rewards.\"},\"executionFee(uint256,bytes32)\":{\"notice\":\"Get the total execution fee for a transaction.\"},\"recordExecutor(uint256,bytes32,address)\":{\"notice\":\"Record the executor (who completed the transaction) for a transaction, and update the accumulated rewards for the executor.\"},\"recordedExecutor(uint256,bytes32)\":{\"notice\":\"Get the address of the recorded executor for a transaction.\"},\"unclaimedRewards(address)\":{\"notice\":\"Get the unclaimed rewards for an executor.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IExecutionFees\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"accumulatedRewards(address)":"73f273fc","addExecutionFee(uint256,bytes32)":"ffecec7e","claimExecutionFees(address)":"4e497dac","executionFee(uint256,bytes32)":"936fd4db","recordExecutor(uint256,bytes32,address)":"0676b706","recordedExecutor(uint256,bytes32)":"d01e09a6","unclaimedRewards(address)":"949813b8"}},"solidity/InterchainClientV1.sol:IExecutionService":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"executorEOA","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"getExecutionFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"txPayloadSize","type":"uint256"},{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"executionFee","type":"uint256"},{"internalType":"bytes","name":"options","type":"bytes"}],"name":"requestExecution","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"executorEOA()":{"notice":"Get the address of the EOA account that will be used to execute transactions on the remote chains."},"getExecutionFee(uint256,uint256,bytes)":{"notice":"Get the execution fee for executing an Interchain Transaction on a remote chain."},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"notice":"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getExecutionFee(uint256,uint256,bytes)":{"params":{"dstChainId":"The chain id of the destination chain.","options":"The options to use for the execution.","txPayloadSize":"The size of the transaction payload to use for the execution."}},"requestExecution(uint256,uint256,bytes32,uint256,bytes)":{"details":"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.","params":{"dstChainId":"The chain id of the destination chain.","executionFee":"The fee paid for the execution.","options":"The options to use for the execution.","transactionId":"The id of the transaction to execute.","txPayloadSize":"The size of the transaction payload to use for the execution."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"executorEOA\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"getExecutionFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"txPayloadSize\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"}],\"name\":\"requestExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getExecutionFee(uint256,uint256,bytes)\":{\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"options\":\"The options to use for the execution.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"details\":\"Could only be called by `InterchainClient` contracts. Will revert if the execution fee is not big enough.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain.\",\"executionFee\":\"The fee paid for the execution.\",\"options\":\"The options to use for the execution.\",\"transactionId\":\"The id of the transaction to execute.\",\"txPayloadSize\":\"The size of the transaction payload to use for the execution.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"executorEOA()\":{\"notice\":\"Get the address of the EOA account that will be used to execute transactions on the remote chains.\"},\"getExecutionFee(uint256,uint256,bytes)\":{\"notice\":\"Get the execution fee for executing an Interchain Transaction on a remote chain.\"},\"requestExecution(uint256,uint256,bytes32,uint256,bytes)\":{\"notice\":\"Request the execution of an Interchain Transaction on a remote chain. Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient event with the same transactionId, then execute the transaction on the remote chain: `dstInterchainClient.executeTransaction(transactionPayload)` Once the execution is confirmed on the source chain, the off-chain actor will be able to claim `executionFee` in the ExecutionFees contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IExecutionService\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"executorEOA()":"62014bad","getExecutionFee(uint256,uint256,bytes)":"c473e7e8","requestExecution(uint256,uint256,bytes32,uint256,bytes)":"e4e06522"}},"solidity/InterchainClientV1.sol:IInterchainApp":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."}},"notice":"Minimal interface for the Interchain App to work with the Interchain Client.","version":1},"developerDoc":{"kind":"dev","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"}},\"notice\":\"Minimal interface for the Interchain App to work with the Interchain Client.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IInterchainApp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getReceivingConfig()":"287bc057"}},"solidity/InterchainClientV1.sol:IInterchainClientV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__FeeAmountTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__IncorrectDstChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__IncorrectMsgValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NoLinkedClient","type":"error"},{"inputs":[{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"InterchainClientV1__NotEVMClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__NotEnoughResponses","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NotRemoteChainId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxAlreadyExecuted","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxNotExecuted","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroReceiver","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroRequiredResponses","type":"error"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"}],"name":"getExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getExecutorById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"uint256","name":"messageLen","type":"uint256"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClient","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClientEVM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"interchainExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSend","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSendEVM","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"isExecutable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"executionFees_","type":"address"}],"name":"setExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"setLinkedClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"writeExecutionProof","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"getExecutor(bytes)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getExecutorById(bytes32)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getInterchainFee(uint256,address,address[],bytes,uint256)":{"notice":"Returns the fee for sending an Interchain message."},"getLinkedClient(uint256)":{"notice":"Returns the address of the linked client (as bytes32) for a specific chain ID."},"getLinkedClientEVM(uint256)":{"notice":"Returns the EVM address of the linked client for a specific chain ID."},"interchainExecute(uint256,bytes,bytes32[])":{"notice":"Executes a transaction that has been sent via the Interchain."},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"notice":"Sends a message to another chain via the Interchain Communication Protocol."},"isExecutable(bytes,bytes32[])":{"notice":"Checks if a transaction is executable."},"setExecutionFees(address)":{"notice":"Sets the address of the ExecutionFees contract."},"setLinkedClient(uint256,bytes32)":{"notice":"Sets the linked client for a specific chain ID."},"writeExecutionProof(bytes32)":{"notice":"Writes the proof of execution for a transaction into the InterchainDB."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getInterchainFee(uint256,address,address[],bytes,uint256)":{"params":{"dstChainId":"The chain ID of the destination chain.","messageLen":"The length of the message being sent.","options":"Execution options for the message sent, currently gas limit + native gas drop.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."}},"getLinkedClient(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID."},"getLinkedClientEVM(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client."},"interchainExecute(uint256,bytes,bytes32[])":{"details":"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.","params":{"gasLimit":"The gas limit to use for the execution.","proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The transaction data."}},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"details":"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.","params":{"dstChainId":"The chain ID of the destination chain.","message":"The message being sent.","options":"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.","receiver":"The address of the receiver on the destination chain.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."},"returns":{"desc":"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch."}},"isExecutable(bytes,bytes32[])":{"details":"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules","params":{"proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The InterchainTransaction struct to be checked."},"returns":{"_0":"bool Returns true if the transaction is executable, false otherwise."}},"setExecutionFees(address)":{"details":"Only callable by the contract owner or an authorized account.","params":{"executionFees_":"The address of the ExecutionFees contract."}},"setLinkedClient(uint256,bytes32)":{"details":"Stores the address of the linked client in a mapping with the chain ID as the key.","params":{"chainId":"The chain ID for which the client is being set.","client":"The address of the client being linked."}},"writeExecutionProof(bytes32)":{"details":"Will revert if the transaction has not been executed.","params":{"transactionId":"The ID of the transaction to write the proof for."},"returns":{"dbNonce":" The database nonce of the batch containing the written proof for transaction.","entryIndex":" The index of the written proof for transaction within the batch."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"messageLen\":\"The length of the message being sent.\",\"options\":\"Execution options for the message sent, currently gas limit + native gas drop.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"}},\"getLinkedClient(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"details\":\"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.\",\"params\":{\"gasLimit\":\"The gas limit to use for the execution.\",\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The transaction data.\"}},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"details\":\"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.\",\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"message\":\"The message being sent.\",\"options\":\"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\",\"receiver\":\"The address of the receiver on the destination chain.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"},\"returns\":{\"desc\":\"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch.\"}},\"isExecutable(bytes,bytes32[])\":{\"details\":\"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules\",\"params\":{\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The InterchainTransaction struct to be checked.\"},\"returns\":{\"_0\":\"bool Returns true if the transaction is executable, false otherwise.\"}},\"setExecutionFees(address)\":{\"details\":\"Only callable by the contract owner or an authorized account.\",\"params\":{\"executionFees_\":\"The address of the ExecutionFees contract.\"}},\"setLinkedClient(uint256,bytes32)\":{\"details\":\"Stores the address of the linked client in a mapping with the chain ID as the key.\",\"params\":{\"chainId\":\"The chain ID for which the client is being set.\",\"client\":\"The address of the client being linked.\"}},\"writeExecutionProof(bytes32)\":{\"details\":\"Will revert if the transaction has not been executed.\",\"params\":{\"transactionId\":\"The ID of the transaction to write the proof for.\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written proof for transaction.\",\"entryIndex\":\" The index of the written proof for transaction within the batch.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getExecutor(bytes)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getExecutorById(bytes32)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"notice\":\"Returns the fee for sending an Interchain message.\"},\"getLinkedClient(uint256)\":{\"notice\":\"Returns the address of the linked client (as bytes32) for a specific chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"notice\":\"Returns the EVM address of the linked client for a specific chain ID.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"notice\":\"Executes a transaction that has been sent via the Interchain.\"},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"notice\":\"Sends a message to another chain via the Interchain Communication Protocol.\"},\"isExecutable(bytes,bytes32[])\":{\"notice\":\"Checks if a transaction is executable.\"},\"setExecutionFees(address)\":{\"notice\":\"Sets the address of the ExecutionFees contract.\"},\"setLinkedClient(uint256,bytes32)\":{\"notice\":\"Sets the linked client for a specific chain ID.\"},\"writeExecutionProof(bytes32)\":{\"notice\":\"Writes the proof of execution for a transaction into the InterchainDB.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IInterchainClientV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"getExecutor(bytes)":"f92a79ff","getExecutorById(bytes32)":"f1a61fac","getInterchainFee(uint256,address,address[],bytes,uint256)":"7a1277db","getLinkedClient(uint256)":"aa102ec4","getLinkedClientEVM(uint256)":"02172a35","interchainExecute(uint256,bytes,bytes32[])":"53b67d74","interchainSend(uint256,bytes32,address,address[],bytes,bytes)":"98939d28","interchainSendEVM(uint256,address,address,address[],bytes,bytes)":"827f940d","isExecutable(bytes,bytes32[])":"1450c281","setExecutionFees(address)":"3dc68b87","setLinkedClient(uint256,bytes32)":"f34234c8","writeExecutionProof(bytes32)":"90e81077"}},"solidity/InterchainClientV1.sol:IInterchainDB":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"InterchainDB__BatchDoesNotExist","type":"error"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"InterchainDB__BatchNotFinalized","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"},{"internalType":"bytes32","name":"existingBatchRoot","type":"bytes32"},{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"bytes32","name":"batchRoot","type":"bytes32"}],"internalType":"struct InterchainBatch","name":"newBatch","type":"tuple"}],"name":"InterchainDB__ConflictingBatches","type":"error"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"uint64","name":"batchSize","type":"uint64"}],"name":"InterchainDB__EntryIndexOutOfRange","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualFee","type":"uint256"},{"internalType":"uint256","name":"expectedFee","type":"uint256"}],"name":"InterchainDB__IncorrectFeeAmount","type":"error"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"}],"name":"InterchainDB__InvalidEntryRange","type":"error"},{"inputs":[],"name":"InterchainDB__NoModulesSpecified","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainDB__SameChainId","type":"error"},{"inputs":[{"internalType":"address","name":"dstModule","type":"address"},{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes32","name":"srcWriter","type":"bytes32"},{"internalType":"bytes32","name":"dataHash","type":"bytes32"}],"internalType":"struct InterchainEntry","name":"entry","type":"tuple"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"checkVerification","outputs":[{"internalType":"uint256","name":"moduleVerifiedAt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"getBatch","outputs":[{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"bytes32","name":"batchRoot","type":"bytes32"}],"internalType":"struct InterchainBatch","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"getBatchLeafs","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"start","type":"uint64"},{"internalType":"uint64","name":"end","type":"uint64"}],"name":"getBatchLeafsPaginated","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"}],"name":"getBatchSize","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDBNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"name":"getEntryProof","outputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"name":"getEntryValue","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address[]","name":"srcModules","type":"address[]"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextEntryIndex","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"address[]","name":"srcModules","type":"address[]"}],"name":"requestBatchVerification","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"bytes32","name":"batchRoot","type":"bytes32"}],"internalType":"struct InterchainBatch","name":"batch","type":"tuple"}],"name":"verifyRemoteBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataHash","type":"bytes32"}],"name":"writeEntry","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"address[]","name":"srcModules","type":"address[]"}],"name":"writeEntryWithVerification","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"payable","type":"function"}],"userDoc":{"kind":"user","methods":{"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])":{"notice":"Read the data written on specific source chain by a specific writer, and verify it on the destination chain using the provided Interchain Module. Note: returned zero value indicates that the module has not verified the entry."},"getBatch(uint256)":{"notice":"Get the finalized Interchain Batch with the given nonce."},"getBatchLeafs(uint256)":{"notice":"Returns the list of leafs of the finalized batch with the given nonce. Note: the leafs are ordered by the index of the written entry in the current batch, and the leafs value match the value of the written entry (srcWriter + dataHash hashed together)."},"getBatchLeafsPaginated(uint256,uint64,uint64)":{"notice":"Returns the list of leafs of the finalized batch with the given nonce, paginated by the given start and end indexes. The end index is exclusive. Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs` would result in a gas limit exceeded error."},"getBatchSize(uint256)":{"notice":"Returns the size of the finalized batch with the given nonce."},"getDBNonce()":{"notice":"Get the nonce of the database, which is incremented every time a new batch is finalized. This is the nonce of the current non-finalized batch."},"getEntryProof(uint256,uint64)":{"notice":"Get the Merkle proof of inclusion for the entry with the given index in the finalized batch with the given nonce."},"getEntryValue(uint256,uint64)":{"notice":"Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index. Entry value is calculated as the hash of the writer address and the written data hash. Note: the batch does not have to be finalized to fetch the entry value."},"getInterchainFee(uint256,address[])":{"notice":"Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain using the provided Interchain Modules."},"getNextEntryIndex()":{"notice":"Get the index of the next entry to be written to the database."},"requestBatchVerification(uint256,uint256,address[])":{"notice":"Request the given Interchain Modules to verify an existing batch. If the batch is not finalized, the module will verify it after finalization. For the finalized batch the batch root is already available, and the module can verify it immediately. Note: every module has a separate fee paid in the native gas token of the source chain, and `msg.value` must be equal to the sum of all fees. Note: this method is permissionless, and anyone can request verification for any batch."},"verifyRemoteBatch((uint256,uint256,bytes32))":{"notice":"Allows the Interchain Module to verify the batch coming from the remote chain."},"writeEntry(bytes32)":{"notice":"Write data to the Interchain DataBase as a new entry in the current batch. Note: there are no guarantees that this entry will be available for reading on any of the remote chains. Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain."},"writeEntryWithVerification(uint256,bytes32,address[])":{"notice":"Write data to the Interchain DataBase as a new entry in the current batch. Then request the Interchain Modules to verify the batch containing the written entry on the destination chain. See `writeEntry` and `requestBatchVerification` for more details."}},"version":1},"developerDoc":{"kind":"dev","methods":{"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])":{"params":{"dstModule":"The destination chain addresses of the Interchain Modules to use for verification","entry":"The Interchain Entry to read"},"returns":{"moduleVerifiedAt":" The block timestamp at which the entry was verified by the module, or ZERO if the module has not verified the entry."}},"getBatch(uint256)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized.","params":{"dbNonce":"The database nonce of the finalized batch"}},"getBatchLeafs(uint256)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized.","params":{"dbNonce":"The database nonce of the finalized batch"}},"getBatchLeafsPaginated(uint256,uint64,uint64)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the provided range is invalid.","params":{"dbNonce":"The database nonce of the finalized batch","end":"The end index of the paginated leafs, exclusive","start":"The start index of the paginated leafs, inclusive"}},"getBatchSize(uint256)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized.","params":{"dbNonce":"The database nonce of the finalized batch"}},"getEntryProof(uint256,uint64)":{"details":"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the entry with the given index does not exist within the batch.","params":{"dbNonce":"The database nonce of the finalized batch","entryIndex":"The index of the written entry within the batch"},"returns":{"proof":" The Merkle proof of inclusion for the entry"}},"getEntryValue(uint256,uint64)":{"details":"Will revert if the batch with the given nonce does not exist, or the entry with the given index does not exist within the batch.","params":{"dbNonce":"The database nonce of the existing batch","entryIndex":"The index of the written entry within the batch"}},"getInterchainFee(uint256,address[])":{"details":"Will revert if the empty array of modules is provided.","params":{"dstChainId":"The chain id of the destination chain","srcModules":"The source chain addresses of the Interchain Modules to use for verification"}},"getNextEntryIndex()":{"returns":{"dbNonce":" The database nonce of the batch including the next entry","entryIndex":" The index of the next entry within that batch"}},"requestBatchVerification(uint256,uint256,address[])":{"details":"Will revert if the batch with the given nonce does not exist.","params":{"dbNonce":"The database nonce of the existing batch","dstChainId":"The chain id of the destination chain","srcModules":"The source chain addresses of the Interchain Modules to use for verification"}},"verifyRemoteBatch((uint256,uint256,bytes32))":{"params":{"batch":"The Interchain Batch to confirm"}},"writeEntry(bytes32)":{"params":{"dataHash":"The hash of the data to be written to the Interchain DataBase as a new entry"},"returns":{"dbNonce":" The database nonce of the batch containing the written entry","entryIndex":" The index of the written entry within the batch"}},"writeEntryWithVerification(uint256,bytes32,address[])":{"details":"Will revert if the empty array of modules is provided.","params":{"dataHash":"The hash of the data to be written to the Interchain DataBase as a new entry","dstChainId":"The chain id of the destination chain","srcModules":"The source chain addresses of the Interchain Modules to use for verification"},"returns":{"dbNonce":" The database nonce of the batch containing the written entry","entryIndex":" The index of the written entry within the batch"}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__BatchDoesNotExist\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__BatchNotFinalized\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"existingBatchRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"batchRoot\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainBatch\",\"name\":\"newBatch\",\"type\":\"tuple\"}],\"name\":\"InterchainDB__ConflictingBatches\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"batchSize\",\"type\":\"uint64\"}],\"name\":\"InterchainDB__EntryIndexOutOfRange\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actualFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"expectedFee\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__IncorrectFeeAmount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"start\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"end\",\"type\":\"uint64\"}],\"name\":\"InterchainDB__InvalidEntryRange\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainDB__NoModulesSpecified\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainDB__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"dstModule\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"srcWriter\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataHash\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainEntry\",\"name\":\"entry\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"checkVerification\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"moduleVerifiedAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"getBatch\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"batchRoot\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainBatch\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"getBatchLeafs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"start\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"end\",\"type\":\"uint64\"}],\"name\":\"getBatchLeafsPaginated\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"}],\"name\":\"getBatchSize\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDBNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"name\":\"getEntryProof\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"name\":\"getEntryValue\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getNextEntryIndex\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"}],\"name\":\"requestBatchVerification\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"batchRoot\",\"type\":\"bytes32\"}],\"internalType\":\"struct InterchainBatch\",\"name\":\"batch\",\"type\":\"tuple\"}],\"name\":\"verifyRemoteBatch\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"dataHash\",\"type\":\"bytes32\"}],\"name\":\"writeEntry\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"dataHash\",\"type\":\"bytes32\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"}],\"name\":\"writeEntryWithVerification\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])\":{\"params\":{\"dstModule\":\"The destination chain addresses of the Interchain Modules to use for verification\",\"entry\":\"The Interchain Entry to read\"},\"returns\":{\"moduleVerifiedAt\":\" The block timestamp at which the entry was verified by the module, or ZERO if the module has not verified the entry.\"}},\"getBatch(uint256)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\"}},\"getBatchLeafs(uint256)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\"}},\"getBatchLeafsPaginated(uint256,uint64,uint64)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the provided range is invalid.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\",\"end\":\"The end index of the paginated leafs, exclusive\",\"start\":\"The start index of the paginated leafs, inclusive\"}},\"getBatchSize(uint256)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\"}},\"getEntryProof(uint256,uint64)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or is not finalized. Will revert if the entry with the given index does not exist within the batch.\",\"params\":{\"dbNonce\":\"The database nonce of the finalized batch\",\"entryIndex\":\"The index of the written entry within the batch\"},\"returns\":{\"proof\":\" The Merkle proof of inclusion for the entry\"}},\"getEntryValue(uint256,uint64)\":{\"details\":\"Will revert if the batch with the given nonce does not exist, or the entry with the given index does not exist within the batch.\",\"params\":{\"dbNonce\":\"The database nonce of the existing batch\",\"entryIndex\":\"The index of the written entry within the batch\"}},\"getInterchainFee(uint256,address[])\":{\"details\":\"Will revert if the empty array of modules is provided.\",\"params\":{\"dstChainId\":\"The chain id of the destination chain\",\"srcModules\":\"The source chain addresses of the Interchain Modules to use for verification\"}},\"getNextEntryIndex()\":{\"returns\":{\"dbNonce\":\" The database nonce of the batch including the next entry\",\"entryIndex\":\" The index of the next entry within that batch\"}},\"requestBatchVerification(uint256,uint256,address[])\":{\"details\":\"Will revert if the batch with the given nonce does not exist.\",\"params\":{\"dbNonce\":\"The database nonce of the existing batch\",\"dstChainId\":\"The chain id of the destination chain\",\"srcModules\":\"The source chain addresses of the Interchain Modules to use for verification\"}},\"verifyRemoteBatch((uint256,uint256,bytes32))\":{\"params\":{\"batch\":\"The Interchain Batch to confirm\"}},\"writeEntry(bytes32)\":{\"params\":{\"dataHash\":\"The hash of the data to be written to the Interchain DataBase as a new entry\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written entry\",\"entryIndex\":\" The index of the written entry within the batch\"}},\"writeEntryWithVerification(uint256,bytes32,address[])\":{\"details\":\"Will revert if the empty array of modules is provided.\",\"params\":{\"dataHash\":\"The hash of the data to be written to the Interchain DataBase as a new entry\",\"dstChainId\":\"The chain id of the destination chain\",\"srcModules\":\"The source chain addresses of the Interchain Modules to use for verification\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written entry\",\"entryIndex\":\" The index of the written entry within the batch\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])\":{\"notice\":\"Read the data written on specific source chain by a specific writer, and verify it on the destination chain using the provided Interchain Module. Note: returned zero value indicates that the module has not verified the entry.\"},\"getBatch(uint256)\":{\"notice\":\"Get the finalized Interchain Batch with the given nonce.\"},\"getBatchLeafs(uint256)\":{\"notice\":\"Returns the list of leafs of the finalized batch with the given nonce. Note: the leafs are ordered by the index of the written entry in the current batch, and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\"},\"getBatchLeafsPaginated(uint256,uint64,uint64)\":{\"notice\":\"Returns the list of leafs of the finalized batch with the given nonce, paginated by the given start and end indexes. The end index is exclusive. Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs` would result in a gas limit exceeded error.\"},\"getBatchSize(uint256)\":{\"notice\":\"Returns the size of the finalized batch with the given nonce.\"},\"getDBNonce()\":{\"notice\":\"Get the nonce of the database, which is incremented every time a new batch is finalized. This is the nonce of the current non-finalized batch.\"},\"getEntryProof(uint256,uint64)\":{\"notice\":\"Get the Merkle proof of inclusion for the entry with the given index in the finalized batch with the given nonce.\"},\"getEntryValue(uint256,uint64)\":{\"notice\":\"Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index. Entry value is calculated as the hash of the writer address and the written data hash. Note: the batch does not have to be finalized to fetch the entry value.\"},\"getInterchainFee(uint256,address[])\":{\"notice\":\"Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain using the provided Interchain Modules.\"},\"getNextEntryIndex()\":{\"notice\":\"Get the index of the next entry to be written to the database.\"},\"requestBatchVerification(uint256,uint256,address[])\":{\"notice\":\"Request the given Interchain Modules to verify an existing batch. If the batch is not finalized, the module will verify it after finalization. For the finalized batch the batch root is already available, and the module can verify it immediately. Note: every module has a separate fee paid in the native gas token of the source chain, and `msg.value` must be equal to the sum of all fees. Note: this method is permissionless, and anyone can request verification for any batch.\"},\"verifyRemoteBatch((uint256,uint256,bytes32))\":{\"notice\":\"Allows the Interchain Module to verify the batch coming from the remote chain.\"},\"writeEntry(bytes32)\":{\"notice\":\"Write data to the Interchain DataBase as a new entry in the current batch. Note: there are no guarantees that this entry will be available for reading on any of the remote chains. Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\"},\"writeEntryWithVerification(uint256,bytes32,address[])\":{\"notice\":\"Write data to the Interchain DataBase as a new entry in the current batch. Then request the Interchain Modules to verify the batch containing the written entry on the destination chain. See `writeEntry` and `requestBatchVerification` for more details.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"IInterchainDB\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"checkVerification(address,(uint256,uint256,uint64,bytes32,bytes32),bytes32[])":"67b1f42e","getBatch(uint256)":"5ac44282","getBatchLeafs(uint256)":"d63020bb","getBatchLeafsPaginated(uint256,uint64,uint64)":"25a1641d","getBatchSize(uint256)":"b955e9b9","getDBNonce()":"f338140e","getEntryProof(uint256,uint64)":"4f84d040","getEntryValue(uint256,uint64)":"afa25005","getInterchainFee(uint256,address[])":"fc7686ec","getNextEntryIndex()":"aa2f06ae","requestBatchVerification(uint256,uint256,address[])":"84b1c8b8","verifyRemoteBatch((uint256,uint256,bytes32))":"05d0728c","writeEntry(bytes32)":"2ad8c706","writeEntryWithVerification(uint256,bytes32,address[])":"67c769af"}},"solidity/InterchainClientV1.sol:InterchainBatchLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d78f7327549c020b1c36cf7060e7190a3a38d9835007bebfdfcf92ad7488691464736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220d78f7327549c020b1c36cf7060e7190a3a38d9835007bebfdfcf92ad7488691464736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"8805:842:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;8805:842:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"8805:842:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainBatchLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:InterchainClientV1":{"code":"0x60a06040523480156200001157600080fd5b5060405162002bd438038062002bd48339810160408190526200003491620000f0565b806001600160a01b0381166200006457604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b6200006f8162000083565b50506001600160a01b031660805262000128565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114620000eb57600080fd5b919050565b600080604083850312156200010457600080fd5b6200010f83620000d3565b91506200011f60208401620000d3565b90509250929050565b608051612a666200016e600039600081816103bd015281816108af01528181610b46015281816113cc0152818161148d015281816115eb0152611bab0152612a666000f3fe6080604052600436106101445760003560e01c80638da5cb5b116100c0578063e4c6124711610074578063f2fde38b11610059578063f2fde38b14610422578063f34234c814610442578063f92a79ff1461046257600080fd5b8063e4c61247146103ab578063f1a61fac146103df57600080fd5b806398939d28116100a557806398939d281461033d578063aa102ec414610350578063d5e788a01461037057600080fd5b80638da5cb5b146102d457806390e81077146102ff57600080fd5b8063715018a6116101175780637a1277db116100fc5780637a1277db1461023a5780637c80a90f14610268578063827f940d1461029557600080fd5b8063715018a6146101f85780637341eaf91461020d57600080fd5b806302172a35146101495780631450c281146101935780633dc68b87146101c357806353b67d74146101e5575b600080fd5b34801561015557600080fd5b50610169610164366004611d6c565b610482565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561019f57600080fd5b506101b36101ae366004611e13565b61052e565b604051901515815260200161018a565b3480156101cf57600080fd5b506101e36101de366004611ea1565b610598565b005b6101e36101f3366004611ebe565b610619565b34801561020457600080fd5b506101e3610812565b34801561021957600080fd5b506001546101699073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024657600080fd5b5061025a610255366004611f38565b610826565b60405190815260200161018a565b34801561027457600080fd5b506102886102833660046120f6565b610a08565b60405161018a919061221b565b6102a86102a336600461222e565b610a19565b6040805182518152602080840151908201529181015167ffffffffffffffff169082015260600161018a565b3480156102e057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610169565b34801561030b57600080fd5b5061031f61031a366004611d6c565b610a6d565b6040805192835267ffffffffffffffff90911660208301520161018a565b6102a861034b3660046122f9565b610c2c565b34801561035c57600080fd5b5061025a61036b366004611d6c565b610c68565b34801561037c57600080fd5b5061039061038b366004612330565b610cb9565b6040805182518152602092830151928101929092520161018a565b3480156103b757600080fd5b506101697f000000000000000000000000000000000000000000000000000000000000000081565b3480156103eb57600080fd5b506101696103fa366004611d6c565b60009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b34801561042e57600080fd5b506101e361043d366004611ea1565b610cd6565b34801561044e57600080fd5b506101e361045d36600461236d565b610d3a565b34801561046e57600080fd5b5061016961047d36600461238f565b610d91565b60004682036104c5576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b506000818152600260205260409020548073ffffffffffffffffffffffffffffffffffffffff81168114610528576040517f0a55a4eb000000000000000000000000000000000000000000000000000000008152600481018290526024016104bc565b50919050565b60008061057086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905061057f8160c00151610e7d565b5061058b818585610f06565b5060019695505050505050565b6105a0611141565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fec02f15d78cdfc4beeba45f31cfad25089004e5e3d72727168dd96a77d1f2f829060200160405180910390a150565b600061065a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b90506000610669828585610f06565b600081815260036020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317905560c0840151919250906106b190610e7d565b9050806020015134146106ff5760208101516040517f2b36102500000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016104bc565b805188101561070d57805197505b606083015173ffffffffffffffffffffffffffffffffffffffff166368a6984789348660000151876020015188608001518960a001518a60e001516040518863ffffffff1660e01b81526004016107689594939291906123d1565b6000604051808303818589803b15801561078157600080fd5b5088f1158015610795573d6000803e3d6000fd5b5050505050508260a0015167ffffffffffffffff168360800151837f9c887f38b8f2330ee9894137eb60cf6ab904c5d2063ddc0baa7a77bfd1880e8c866000015187602001518860600151604051610800939291909283526020830191909152604082015260600190565b60405180910390a45050505050505050565b61081a611141565b6108246000611194565b565b600061083188611209565b5061087184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec906108e8908b908a908a9060040161245c565b602060405180830381865afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610929919061247f565b905073ffffffffffffffffffffffffffffffffffffffff8716156109fd5760006109538484611299565b6040517fc473e7e800000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff89169063c473e7e8906109ae908c9085908a908a906004016124c3565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef919061247f565b6109f9908361251c565b9150505b979650505050505050565b6060610a13826112c1565b92915050565b604080516060810182526000808252602082018190529181019190915273ffffffffffffffffffffffffffffffffffffffff8916610a5e8b828b8b8b8b8b8b8b6112ea565b9b9a5050505050505050505050565b600081815260036020526040812054819073ffffffffffffffffffffffffffffffffffffffff1680610ace576040517fe99eb48d000000000000000000000000000000000000000000000000000000008152600481018590526024016104bc565b60008482604051602001610b0292919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60408051808303601f1901815290829052805160208201207f2ad8c706000000000000000000000000000000000000000000000000000000008352600483015291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632ad8c7069060240160408051808303816000875af1158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc7919061253a565b60405173ffffffffffffffffffffffffffffffffffffffff85168152919550935067ffffffffffffffff841690859087907f810ecf3e461a7f5c46c0bbbca8680cf65de59e78e521d58d569e03969d08648c9060200160405180910390a45050915091565b6040805160608101825260008082526020820181905291810191909152610c5a8a8a8a8a8a8a8a8a8a6112ea565b9a9950505050505050505050565b6000468203610ca6576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060009081526002602052604090205490565b6040805180820190915260008082526020820152610a1382610e7d565b610cde611141565b73ffffffffffffffffffffffffffffffffffffffff8116610d2e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016104bc565b610d3781611194565b50565b610d42611141565b60008281526002602090815260409182902083905581518481529081018390527fb6b5dc04cc1c35fc7a8c8342e378dccc610c6589ef3bcfcd6eaf0304913f889a910160405180910390a15050565b600080610dd384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905060036000610de2836119bf565b815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16949350505050565b610e696040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b81806020019051810190610a1391906125af565b60408051808201909152600080825260208201526000610e9c836119ef565b9050600161ffff82161015610ee3576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff821660048201526024016104bc565b610eec83611a3a565b806020019051810190610eff91906126c4565b9392505050565b600080610f168560000151611209565b905046856040015114610f5d5784604001516040517f973253820000000000000000000000000000000000000000000000000000000081526004016104bc91815260200190565b610f66856119bf565b60008181526003602052604090205490925073ffffffffffffffffffffffffffffffffffffffff1615610fc8576040517fd80aeb91000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b60006040518060a0016040528087600001518152602001876080015181526020018760a0015167ffffffffffffffff168152602001838152602001848152509050600080611017886060015190565b73ffffffffffffffffffffffffffffffffffffffff1663287bc0576040518163ffffffff1660e01b8152600401600060405180830381865afa158015611061573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261108991908101906126e0565b91509150600061109883611b34565b80519091506000036110d6576040517fa09e214300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006110e983868b8b8660200151611b9a565b82519091508110156111345781516040517f0bce4e850000000000000000000000000000000000000000000000000000000081526104bc918391600401918252602082015260400190565b5050505050509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610824576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104bc565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000468203611247576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060008181526002602052604081205490819003611294576040517f9a45110f000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b919050565b6000601f19601f830116601f19601f8501166112b79061016061251c565b610eff919061251c565b6060816040516020016112d491906127b6565b6040516020818303038152906040529050919050565b60408051606081018252600080825260208201819052918101919091526113108a611209565b50600089900361134c576040517f0b3e41a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61138b85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec90611405908e908c908c9060040161245c565b602060405180830381865afa158015611422573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611446919061247f565b90508034101561148b576040517f9557ee49000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016104bc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aa2f06ae6040518163ffffffff1660e01b81526004016040805180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611519919061253a565b83602001846040018267ffffffffffffffff1667ffffffffffffffff1681525082815250505060006115d2338d8d866020015187604001518c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611ca792505050565b90506115dd816119bf565b8360000181815250506000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367c769af85856040015188600001518f8f6040518663ffffffff1660e01b81526004016116519493929190612837565b604080518083038185885af115801561166e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611693919061253a565b915091508460200151821480156116c15750846040015167ffffffffffffffff168167ffffffffffffffff16145b6116cd576116cd612857565b50503482810390831461177657600154604080840151865191517fffecec7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263ffecec7e92859261174392909190600401918252602082015260400190565b6000604051808303818588803b15801561175c57600080fd5b505af1158015611770573d6000803e3d6000fd5b50505050505b73ffffffffffffffffffffffffffffffffffffffff8b161561193f5773ffffffffffffffffffffffffffffffffffffffff8b1663e4e065228e6117b98a89611299565b87516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526117fc9392919087908f908f90600401612886565b600060405180830381600087803b15801561181657600080fd5b505af115801561182a573d6000803e3d6000fd5b5050505060008b73ffffffffffffffffffffffffffffffffffffffff166362014bad6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906128be565b600154604085810151885191517f0676b7060000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915273ffffffffffffffffffffffffffffffffffffffff8084166044830152929350911690630676b70690606401600060405180830381600087803b15801561192557600080fd5b505af1158015611939573d6000803e3d6000fd5b50505050505b8160a0015167ffffffffffffffff16826080015185600001517f1b22d6c0b67f6f17a9004833bfb5afbaea4602457bd57e1d128cb997fb30161b85604001518660200151876060015189888a60c001518b60e001516040516119a797969594939291906128db565b60405180910390a45050509998505050505050505050565b6000816040516020016119d291906127b6565b604051602081830303815290604052805190602001209050919050565b6000600282511015611a2f57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016104bc919061221b565b506020015160f01c90565b6060600282511015611a7a57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016104bc919061221b565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff811115611ab757611ab7611fcd565b6040519080825280601f01601f191660200182016040528015611ae1576020820181803683370190505b50915060008160208401836022870160045afa905080611b2d576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60408051808201909152600080825260208201526000611b53836119ef565b9050600161ffff82161015610ee3576040517faac8bd2300000000000000000000000000000000000000000000000000000000815261ffff821660048201526024016104bc565b6000805b8651811015611c9d5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367b1f42e898481518110611bf757611bf761291e565b60200260200101518989896040518563ffffffff1660e01b8152600401611c21949392919061294d565b602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c62919061247f565b90508015801590611c7b575042611c79858361251c565b105b15611c8c57611c89836129f8565b92505b50611c96816129f8565b9050611b9e565b5095945050505050565b611cff6040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b604051806101000160405280468152602001611d2e8a73ffffffffffffffffffffffffffffffffffffffff1690565b81526020018881526020018781526020018681526020018567ffffffffffffffff168152602001848152602001838152509050979650505050505050565b600060208284031215611d7e57600080fd5b5035919050565b60008083601f840112611d9757600080fd5b50813567ffffffffffffffff811115611daf57600080fd5b602083019150836020828501011115611dc757600080fd5b9250929050565b60008083601f840112611de057600080fd5b50813567ffffffffffffffff811115611df857600080fd5b6020830191508360208260051b8501011115611dc757600080fd5b60008060008060408587031215611e2957600080fd5b843567ffffffffffffffff80821115611e4157600080fd5b611e4d88838901611d85565b90965094506020870135915080821115611e6657600080fd5b50611e7387828801611dce565b95989497509550505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d3757600080fd5b600060208284031215611eb357600080fd5b8135610eff81611e7f565b600080600080600060608688031215611ed657600080fd5b85359450602086013567ffffffffffffffff80821115611ef557600080fd5b611f0189838a01611d85565b90965094506040880135915080821115611f1a57600080fd5b50611f2788828901611dce565b969995985093965092949392505050565b600080600080600080600060a0888a031215611f5357600080fd5b873596506020880135611f6581611e7f565b9550604088013567ffffffffffffffff80821115611f8257600080fd5b611f8e8b838c01611dce565b909750955060608a0135915080821115611fa757600080fd5b50611fb48a828b01611d85565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff8111828210171561202057612020611fcd565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561204f5761204f611fcd565b604052919050565b67ffffffffffffffff81168114610d3757600080fd5b803561129481612057565b600067ffffffffffffffff82111561209257612092611fcd565b50601f01601f191660200190565b600082601f8301126120b157600080fd5b81356120c46120bf82612078565b612026565b8181528460208386010111156120d957600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561210857600080fd5b813567ffffffffffffffff8082111561212057600080fd5b90830190610100828603121561213557600080fd5b61213d611ffc565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015261217560a0840161206d565b60a082015260c08301358281111561218c57600080fd5b612198878286016120a0565b60c08301525060e0830135828111156121b057600080fd5b6121bc878286016120a0565b60e08301525095945050505050565b60005b838110156121e65781810151838201526020016121ce565b50506000910152565b600081518084526122078160208601602086016121cb565b601f01601f19169290920160200192915050565b602081526000610eff60208301846121ef565b600080600080600080600080600060c08a8c03121561224c57600080fd5b8935985060208a013561225e81611e7f565b975060408a013561226e81611e7f565b965060608a013567ffffffffffffffff8082111561228b57600080fd5b6122978d838e01611dce565b909850965060808c01359150808211156122b057600080fd5b6122bc8d838e01611d85565b909650945060a08c01359150808211156122d557600080fd5b506122e28c828d01611d85565b915080935050809150509295985092959850929598565b600080600080600080600080600060c08a8c03121561231757600080fd5b8935985060208a0135975060408a013561226e81611e7f565b60006020828403121561234257600080fd5b813567ffffffffffffffff81111561235957600080fd5b612365848285016120a0565b949350505050565b6000806040838503121561238057600080fd5b50508035926020909101359150565b600080602083850312156123a257600080fd5b823567ffffffffffffffff8111156123b957600080fd5b6123c585828601611d85565b90969095509350505050565b85815284602082015283604082015267ffffffffffffffff8316606082015260a0608082015260006109fd60a08301846121ef565b8183526000602080850194508260005b8581101561245157813561242981611e7f565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101612416565b509495945050505050565b838152604060208201526000612476604083018486612406565b95945050505050565b60006020828403121561249157600080fd5b5051919050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b8481528360208201526060604082015260006124e3606083018486612498565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610a1357610a136124ed565b805161129481612057565b6000806040838503121561254d57600080fd5b82519150602083015161255f81612057565b809150509250929050565b600082601f83011261257b57600080fd5b81516125896120bf82612078565b81815284602083860101111561259e57600080fd5b6123658260208301602087016121cb565b6000602082840312156125c157600080fd5b815167ffffffffffffffff808211156125d957600080fd5b9083019061010082860312156125ee57600080fd5b6125f6611ffc565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015261262e60a0840161252f565b60a082015260c08301518281111561264557600080fd5b6126518782860161256a565b60c08301525060e08301518281111561266957600080fd5b6121bc8782860161256a565b60006040828403121561268757600080fd5b6040516040810181811067ffffffffffffffff821117156126aa576126aa611fcd565b604052825181526020928301519281019290925250919050565b6000604082840312156126d657600080fd5b610eff8383612675565b600080604083850312156126f357600080fd5b825167ffffffffffffffff8082111561270b57600080fd5b6127178683870161256a565b935060209150818501518181111561272e57600080fd5b8501601f8101871361273f57600080fd5b80518281111561275157612751611fcd565b8060051b9250612762848401612026565b818152928201840192848101908985111561277c57600080fd5b928501925b848410156127a6578351925061279683611e7f565b8282529285019290850190612781565b8096505050505050509250929050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015267ffffffffffffffff60a08301511660c0820152600060c08301516101008060e085015261281b6101208501836121ef565b915060e0850151601f1985840301828601526124e383826121ef565b8481528360208201526060604082015260006124e3606083018486612406565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b86815285602082015284604082015283606082015260a0608082015260006128b260a083018486612498565b98975050505050505050565b6000602082840312156128d057600080fd5b8151610eff81611e7f565b87815286602082015285604082015284606082015283608082015260e060a0820152600061290c60e08301856121ef565b82810360c0840152610c5a81856121ef565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff85168152835160208201526020840151604082015267ffffffffffffffff604085015116606082015260608401516080820152608084015160a082015260e060c08201528160e082015260006101007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8411156129de57600080fd5b8360051b8086838601379290920190910195945050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612a2957612a296124ed565b506001019056fea2646970667358221220efec5b8efc94ceff35688c624c61b3f55ac46dfae8b34b0d0bbd373b1de4af8664736f6c63430008140033","runtime-code":"0x6080604052600436106101445760003560e01c80638da5cb5b116100c0578063e4c6124711610074578063f2fde38b11610059578063f2fde38b14610422578063f34234c814610442578063f92a79ff1461046257600080fd5b8063e4c61247146103ab578063f1a61fac146103df57600080fd5b806398939d28116100a557806398939d281461033d578063aa102ec414610350578063d5e788a01461037057600080fd5b80638da5cb5b146102d457806390e81077146102ff57600080fd5b8063715018a6116101175780637a1277db116100fc5780637a1277db1461023a5780637c80a90f14610268578063827f940d1461029557600080fd5b8063715018a6146101f85780637341eaf91461020d57600080fd5b806302172a35146101495780631450c281146101935780633dc68b87146101c357806353b67d74146101e5575b600080fd5b34801561015557600080fd5b50610169610164366004611d6c565b610482565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561019f57600080fd5b506101b36101ae366004611e13565b61052e565b604051901515815260200161018a565b3480156101cf57600080fd5b506101e36101de366004611ea1565b610598565b005b6101e36101f3366004611ebe565b610619565b34801561020457600080fd5b506101e3610812565b34801561021957600080fd5b506001546101699073ffffffffffffffffffffffffffffffffffffffff1681565b34801561024657600080fd5b5061025a610255366004611f38565b610826565b60405190815260200161018a565b34801561027457600080fd5b506102886102833660046120f6565b610a08565b60405161018a919061221b565b6102a86102a336600461222e565b610a19565b6040805182518152602080840151908201529181015167ffffffffffffffff169082015260600161018a565b3480156102e057600080fd5b5060005473ffffffffffffffffffffffffffffffffffffffff16610169565b34801561030b57600080fd5b5061031f61031a366004611d6c565b610a6d565b6040805192835267ffffffffffffffff90911660208301520161018a565b6102a861034b3660046122f9565b610c2c565b34801561035c57600080fd5b5061025a61036b366004611d6c565b610c68565b34801561037c57600080fd5b5061039061038b366004612330565b610cb9565b6040805182518152602092830151928101929092520161018a565b3480156103b757600080fd5b506101697f000000000000000000000000000000000000000000000000000000000000000081565b3480156103eb57600080fd5b506101696103fa366004611d6c565b60009081526003602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b34801561042e57600080fd5b506101e361043d366004611ea1565b610cd6565b34801561044e57600080fd5b506101e361045d36600461236d565b610d3a565b34801561046e57600080fd5b5061016961047d36600461238f565b610d91565b60004682036104c5576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024015b60405180910390fd5b506000818152600260205260409020548073ffffffffffffffffffffffffffffffffffffffff81168114610528576040517f0a55a4eb000000000000000000000000000000000000000000000000000000008152600481018290526024016104bc565b50919050565b60008061057086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905061057f8160c00151610e7d565b5061058b818585610f06565b5060019695505050505050565b6105a0611141565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527fec02f15d78cdfc4beeba45f31cfad25089004e5e3d72727168dd96a77d1f2f829060200160405180910390a150565b600061065a85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b90506000610669828585610f06565b600081815260036020526040812080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317905560c0840151919250906106b190610e7d565b9050806020015134146106ff5760208101516040517f2b36102500000000000000000000000000000000000000000000000000000000815234600482015260248101919091526044016104bc565b805188101561070d57805197505b606083015173ffffffffffffffffffffffffffffffffffffffff166368a6984789348660000151876020015188608001518960a001518a60e001516040518863ffffffff1660e01b81526004016107689594939291906123d1565b6000604051808303818589803b15801561078157600080fd5b5088f1158015610795573d6000803e3d6000fd5b5050505050508260a0015167ffffffffffffffff168360800151837f9c887f38b8f2330ee9894137eb60cf6ab904c5d2063ddc0baa7a77bfd1880e8c866000015187602001518860600151604051610800939291909283526020830191909152604082015260600190565b60405180910390a45050505050505050565b61081a611141565b6108246000611194565b565b600061083188611209565b5061087184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec906108e8908b908a908a9060040161245c565b602060405180830381865afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610929919061247f565b905073ffffffffffffffffffffffffffffffffffffffff8716156109fd5760006109538484611299565b6040517fc473e7e800000000000000000000000000000000000000000000000000000000815290915073ffffffffffffffffffffffffffffffffffffffff89169063c473e7e8906109ae908c9085908a908a906004016124c3565b602060405180830381865afa1580156109cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ef919061247f565b6109f9908361251c565b9150505b979650505050505050565b6060610a13826112c1565b92915050565b604080516060810182526000808252602082018190529181019190915273ffffffffffffffffffffffffffffffffffffffff8916610a5e8b828b8b8b8b8b8b8b6112ea565b9b9a5050505050505050505050565b600081815260036020526040812054819073ffffffffffffffffffffffffffffffffffffffff1680610ace576040517fe99eb48d000000000000000000000000000000000000000000000000000000008152600481018590526024016104bc565b60008482604051602001610b0292919091825273ffffffffffffffffffffffffffffffffffffffff16602082015260400190565b60408051808303601f1901815290829052805160208201207f2ad8c706000000000000000000000000000000000000000000000000000000008352600483015291507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632ad8c7069060240160408051808303816000875af1158015610ba3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc7919061253a565b60405173ffffffffffffffffffffffffffffffffffffffff85168152919550935067ffffffffffffffff841690859087907f810ecf3e461a7f5c46c0bbbca8680cf65de59e78e521d58d569e03969d08648c9060200160405180910390a45050915091565b6040805160608101825260008082526020820181905291810191909152610c5a8a8a8a8a8a8a8a8a8a6112ea565b9a9950505050505050505050565b6000468203610ca6576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060009081526002602052604090205490565b6040805180820190915260008082526020820152610a1382610e7d565b610cde611141565b73ffffffffffffffffffffffffffffffffffffffff8116610d2e576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016104bc565b610d3781611194565b50565b610d42611141565b60008281526002602090815260409182902083905581518481529081018390527fb6b5dc04cc1c35fc7a8c8342e378dccc610c6589ef3bcfcd6eaf0304913f889a910160405180910390a15050565b600080610dd384848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e1192505050565b905060036000610de2836119bf565b815260208101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff16949350505050565b610e696040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b81806020019051810190610a1391906125af565b60408051808201909152600080825260208201526000610e9c836119ef565b9050600161ffff82161015610ee3576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff821660048201526024016104bc565b610eec83611a3a565b806020019051810190610eff91906126c4565b9392505050565b600080610f168560000151611209565b905046856040015114610f5d5784604001516040517f973253820000000000000000000000000000000000000000000000000000000081526004016104bc91815260200190565b610f66856119bf565b60008181526003602052604090205490925073ffffffffffffffffffffffffffffffffffffffff1615610fc8576040517fd80aeb91000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b60006040518060a0016040528087600001518152602001876080015181526020018760a0015167ffffffffffffffff168152602001838152602001848152509050600080611017886060015190565b73ffffffffffffffffffffffffffffffffffffffff1663287bc0576040518163ffffffff1660e01b8152600401600060405180830381865afa158015611061573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261108991908101906126e0565b91509150600061109883611b34565b80519091506000036110d6576040517fa09e214300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006110e983868b8b8660200151611b9a565b82519091508110156111345781516040517f0bce4e850000000000000000000000000000000000000000000000000000000081526104bc918391600401918252602082015260400190565b5050505050509392505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610824576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016104bc565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000468203611247576040517f57516f69000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b5060008181526002602052604081205490819003611294576040517f9a45110f000000000000000000000000000000000000000000000000000000008152600481018390526024016104bc565b919050565b6000601f19601f830116601f19601f8501166112b79061016061251c565b610eff919061251c565b6060816040516020016112d491906127b6565b6040516020818303038152906040529050919050565b60408051606081018252600080825260208201819052918101919091526113108a611209565b50600089900361134c576040517f0b3e41a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61138b85858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e7d92505050565b506040517ffc7686ec00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063fc7686ec90611405908e908c908c9060040161245c565b602060405180830381865afa158015611422573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611446919061247f565b90508034101561148b576040517f9557ee49000000000000000000000000000000000000000000000000000000008152346004820152602481018290526044016104bc565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663aa2f06ae6040518163ffffffff1660e01b81526004016040805180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611519919061253a565b83602001846040018267ffffffffffffffff1667ffffffffffffffff1681525082815250505060006115d2338d8d866020015187604001518c8c8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508b8b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611ca792505050565b90506115dd816119bf565b8360000181815250506000807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367c769af85856040015188600001518f8f6040518663ffffffff1660e01b81526004016116519493929190612837565b604080518083038185885af115801561166e573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611693919061253a565b915091508460200151821480156116c15750846040015167ffffffffffffffff168167ffffffffffffffff16145b6116cd576116cd612857565b50503482810390831461177657600154604080840151865191517fffecec7e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9093169263ffecec7e92859261174392909190600401918252602082015260400190565b6000604051808303818588803b15801561175c57600080fd5b505af1158015611770573d6000803e3d6000fd5b50505050505b73ffffffffffffffffffffffffffffffffffffffff8b161561193f5773ffffffffffffffffffffffffffffffffffffffff8b1663e4e065228e6117b98a89611299565b87516040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b1681526117fc9392919087908f908f90600401612886565b600060405180830381600087803b15801561181657600080fd5b505af115801561182a573d6000803e3d6000fd5b5050505060008b73ffffffffffffffffffffffffffffffffffffffff166362014bad6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906128be565b600154604085810151885191517f0676b7060000000000000000000000000000000000000000000000000000000081526004810191909152602481019190915273ffffffffffffffffffffffffffffffffffffffff8084166044830152929350911690630676b70690606401600060405180830381600087803b15801561192557600080fd5b505af1158015611939573d6000803e3d6000fd5b50505050505b8160a0015167ffffffffffffffff16826080015185600001517f1b22d6c0b67f6f17a9004833bfb5afbaea4602457bd57e1d128cb997fb30161b85604001518660200151876060015189888a60c001518b60e001516040516119a797969594939291906128db565b60405180910390a45050509998505050505050505050565b6000816040516020016119d291906127b6565b604051602081830303815290604052805190602001209050919050565b6000600282511015611a2f57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016104bc919061221b565b506020015160f01c90565b6060600282511015611a7a57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016104bc919061221b565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff811115611ab757611ab7611fcd565b6040519080825280601f01601f191660200182016040528015611ae1576020820181803683370190505b50915060008160208401836022870160045afa905080611b2d576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60408051808201909152600080825260208201526000611b53836119ef565b9050600161ffff82161015610ee3576040517faac8bd2300000000000000000000000000000000000000000000000000000000815261ffff821660048201526024016104bc565b6000805b8651811015611c9d5760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166367b1f42e898481518110611bf757611bf761291e565b60200260200101518989896040518563ffffffff1660e01b8152600401611c21949392919061294d565b602060405180830381865afa158015611c3e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c62919061247f565b90508015801590611c7b575042611c79858361251c565b105b15611c8c57611c89836129f8565b92505b50611c96816129f8565b9050611b9e565b5095945050505050565b611cff6040518061010001604052806000815260200160008019168152602001600081526020016000801916815260200160008152602001600067ffffffffffffffff16815260200160608152602001606081525090565b604051806101000160405280468152602001611d2e8a73ffffffffffffffffffffffffffffffffffffffff1690565b81526020018881526020018781526020018681526020018567ffffffffffffffff168152602001848152602001838152509050979650505050505050565b600060208284031215611d7e57600080fd5b5035919050565b60008083601f840112611d9757600080fd5b50813567ffffffffffffffff811115611daf57600080fd5b602083019150836020828501011115611dc757600080fd5b9250929050565b60008083601f840112611de057600080fd5b50813567ffffffffffffffff811115611df857600080fd5b6020830191508360208260051b8501011115611dc757600080fd5b60008060008060408587031215611e2957600080fd5b843567ffffffffffffffff80821115611e4157600080fd5b611e4d88838901611d85565b90965094506020870135915080821115611e6657600080fd5b50611e7387828801611dce565b95989497509550505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610d3757600080fd5b600060208284031215611eb357600080fd5b8135610eff81611e7f565b600080600080600060608688031215611ed657600080fd5b85359450602086013567ffffffffffffffff80821115611ef557600080fd5b611f0189838a01611d85565b90965094506040880135915080821115611f1a57600080fd5b50611f2788828901611dce565b969995985093965092949392505050565b600080600080600080600060a0888a031215611f5357600080fd5b873596506020880135611f6581611e7f565b9550604088013567ffffffffffffffff80821115611f8257600080fd5b611f8e8b838c01611dce565b909750955060608a0135915080821115611fa757600080fd5b50611fb48a828b01611d85565b989b979a50959894979596608090950135949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff8111828210171561202057612020611fcd565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561204f5761204f611fcd565b604052919050565b67ffffffffffffffff81168114610d3757600080fd5b803561129481612057565b600067ffffffffffffffff82111561209257612092611fcd565b50601f01601f191660200190565b600082601f8301126120b157600080fd5b81356120c46120bf82612078565b612026565b8181528460208386010111156120d957600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561210857600080fd5b813567ffffffffffffffff8082111561212057600080fd5b90830190610100828603121561213557600080fd5b61213d611ffc565b823581526020830135602082015260408301356040820152606083013560608201526080830135608082015261217560a0840161206d565b60a082015260c08301358281111561218c57600080fd5b612198878286016120a0565b60c08301525060e0830135828111156121b057600080fd5b6121bc878286016120a0565b60e08301525095945050505050565b60005b838110156121e65781810151838201526020016121ce565b50506000910152565b600081518084526122078160208601602086016121cb565b601f01601f19169290920160200192915050565b602081526000610eff60208301846121ef565b600080600080600080600080600060c08a8c03121561224c57600080fd5b8935985060208a013561225e81611e7f565b975060408a013561226e81611e7f565b965060608a013567ffffffffffffffff8082111561228b57600080fd5b6122978d838e01611dce565b909850965060808c01359150808211156122b057600080fd5b6122bc8d838e01611d85565b909650945060a08c01359150808211156122d557600080fd5b506122e28c828d01611d85565b915080935050809150509295985092959850929598565b600080600080600080600080600060c08a8c03121561231757600080fd5b8935985060208a0135975060408a013561226e81611e7f565b60006020828403121561234257600080fd5b813567ffffffffffffffff81111561235957600080fd5b612365848285016120a0565b949350505050565b6000806040838503121561238057600080fd5b50508035926020909101359150565b600080602083850312156123a257600080fd5b823567ffffffffffffffff8111156123b957600080fd5b6123c585828601611d85565b90969095509350505050565b85815284602082015283604082015267ffffffffffffffff8316606082015260a0608082015260006109fd60a08301846121ef565b8183526000602080850194508260005b8581101561245157813561242981611e7f565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101612416565b509495945050505050565b838152604060208201526000612476604083018486612406565b95945050505050565b60006020828403121561249157600080fd5b5051919050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b8481528360208201526060604082015260006124e3606083018486612498565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80820180821115610a1357610a136124ed565b805161129481612057565b6000806040838503121561254d57600080fd5b82519150602083015161255f81612057565b809150509250929050565b600082601f83011261257b57600080fd5b81516125896120bf82612078565b81815284602083860101111561259e57600080fd5b6123658260208301602087016121cb565b6000602082840312156125c157600080fd5b815167ffffffffffffffff808211156125d957600080fd5b9083019061010082860312156125ee57600080fd5b6125f6611ffc565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015261262e60a0840161252f565b60a082015260c08301518281111561264557600080fd5b6126518782860161256a565b60c08301525060e08301518281111561266957600080fd5b6121bc8782860161256a565b60006040828403121561268757600080fd5b6040516040810181811067ffffffffffffffff821117156126aa576126aa611fcd565b604052825181526020928301519281019290925250919050565b6000604082840312156126d657600080fd5b610eff8383612675565b600080604083850312156126f357600080fd5b825167ffffffffffffffff8082111561270b57600080fd5b6127178683870161256a565b935060209150818501518181111561272e57600080fd5b8501601f8101871361273f57600080fd5b80518281111561275157612751611fcd565b8060051b9250612762848401612026565b818152928201840192848101908985111561277c57600080fd5b928501925b848410156127a6578351925061279683611e7f565b8282529285019290850190612781565b8096505050505050509250929050565b6020815281516020820152602082015160408201526040820151606082015260608201516080820152608082015160a082015267ffffffffffffffff60a08301511660c0820152600060c08301516101008060e085015261281b6101208501836121ef565b915060e0850151601f1985840301828601526124e383826121ef565b8481528360208201526060604082015260006124e3606083018486612406565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b86815285602082015284604082015283606082015260a0608082015260006128b260a083018486612498565b98975050505050505050565b6000602082840312156128d057600080fd5b8151610eff81611e7f565b87815286602082015285604082015284606082015283608082015260e060a0820152600061290c60e08301856121ef565b82810360c0840152610c5a81856121ef565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff85168152835160208201526020840151604082015267ffffffffffffffff604085015116606082015260608401516080820152608084015160a082015260e060c08201528160e082015260006101007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8411156129de57600080fd5b8360051b8086838601379290920190910195945050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612a2957612a296124ed565b506001019056fea2646970667358221220efec5b8efc94ceff35688c624c61b3f55ac46dfae8b34b0d0bbd373b1de4af8664736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"43272:15002:0:-:0;;;44017:111;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;44075:6;-1:-1:-1;;;;;22107:26:0;;22103:95;;22156:31;;-1:-1:-1;;;22156:31:0;;22184:1;22156:31;;;640:51:1;613:18;;22156:31:0;;;;;;;22103:95;22207:32;22226:12;22207:18;:32::i;:::-;-1:-1:-1;;;;;;;44093:28:0::1;;::::0;43272:15002;;23746:187;23819:16;23838:6;;-1:-1:-1;;;;;23854:17:0;;;-1:-1:-1;;;;;;23854:17:0;;;;;;23886:40;;23838:6;;;;;;;23886:40;;23819:16;23886:40;23809:124;23746:187;:::o;14:177:1:-;93:13;;-1:-1:-1;;;;;135:31:1;;125:42;;115:70;;181:1;178;171:12;115:70;14:177;;;:::o;196:293::-;275:6;283;336:2;324:9;315:7;311:23;307:32;304:52;;;352:1;349;342:12;304:52;375:40;405:9;375:40;:::i;:::-;365:50;;434:49;479:2;468:9;464:18;434:49;:::i;:::-;424:59;;196:293;;;;;:::o;494:203::-;43272:15002:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"43272:15002:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;50192:571;;;;;;;;;;-1:-1:-1;50192:571:0;;;;;:::i;:::-;;:::i;:::-;;;375:42:1;363:55;;;345:74;;333:2;318:18;50192:571:0;;;;;;;;48135:357;;;;;;;;;;-1:-1:-1;48135:357:0;;;;;:::i;:::-;;:::i;:::-;;;2069:14:1;;2062:22;2044:41;;2032:2;2017:18;48135:357:0;1904:187:1;44173:163:0;;;;;;;;;;-1:-1:-1;44173:163:0;;;;;:::i;:::-;;:::i;:::-;;45741:1445;;;;;;:::i;:::-;;:::i;23127:101::-;;;;;;;;;;;;;:::i;43659:28::-;;;;;;;;;;-1:-1:-1;43659:28:0;;;;;;;;48992:872;;;;;;;;;;-1:-1:-1;48992:872:0;;;;;:::i;:::-;;:::i;:::-;;;4494:25:1;;;4482:2;4467:18;48992:872:0;4348:177:1;51064:147:0;;;;;;;;;;-1:-1:-1;51064:147:0;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;45069:508::-;;;;;;:::i;:::-;;:::i;:::-;;;;9904:13:1;;9886:32;;9974:4;9962:17;;;9956:24;9934:20;;;9927:54;10029:17;;;10023:24;10049:18;10019:49;9997:20;;;9990:79;9874:2;9859:18;45069:508:0;9662:413:1;22472:85:0;;;;;;;;;;-1:-1:-1;22518:7:0;22544:6;;;22472:85;;47232:524;;;;;;;;;;-1:-1:-1;47232:524:0;;;;;:::i;:::-;;:::i;:::-;;;;10437:25:1;;;10510:18;10498:31;;;10493:2;10478:18;;10471:59;10410:18;47232:524:0;10265:271:1;44598:426:0;;;;;;:::i;:::-;;:::i;49910:236::-;;;;;;;;;;-1:-1:-1;49910:236:0;;;;;:::i;:::-;;:::i;50843:149::-;;;;;;;;;;-1:-1:-1;50843:149:0;;;;;:::i;:::-;;:::i;:::-;;;;12575:13:1;;12557:32;;12645:4;12633:17;;;12627:24;12605:20;;;12598:54;;;;12530:18;50843:149:0;12359:299:1;43516:38:0;;;;;;;;;;;;;;;48817:130;;;;;;;;;;-1:-1:-1;48817:130:0;;;;;:::i;:::-;48888:7;48914:26;;;:11;:26;;;;;;;;;48817:130;23377:215;;;;;;;;;;-1:-1:-1;23377:215:0;;;;;:::i;:::-;;:::i;44381:172::-;;;;;;;;;;-1:-1:-1;44381:172:0;;;;;:::i;:::-;;:::i;48537:235::-;;;;;;;;;;-1:-1:-1;48537:235:0;;;;;:::i;:::-;;:::i;50192:571::-;50260:23;50310:13;50299:7;:24;50295:107;;50346:45;;;;;;;;4494:25:1;;;4467:18;;50346:45:0;;;;;;;;50295:107;-1:-1:-1;50411:20:0;50434:22;;;:13;:22;;;;;;;10236;;;50618:59;;50614:143;;50700:46;;;;;;;;4494:25:1;;;4467:18;;50700:46:0;4348:177:1;50614:143:0;50285:478;50192:571;;;:::o;48135:357::-;48232:4;48248:33;48284:53;48327:9;;48284:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;48284:42:0;;-1:-1:-1;;;48284:53:0:i;:::-;48248:89;;48394:30;:4;:12;;;:28;:30::i;:::-;;48434;48452:4;48458:5;;48434:17;:30::i;:::-;-1:-1:-1;48481:4:0;;48135:357;-1:-1:-1;;;;;;48135:357:0:o;44173:163::-;22365:13;:11;:13::i;:::-;44252::::1;:30:::0;;;::::1;;::::0;::::1;::::0;;::::1;::::0;;;44297:32:::1;::::0;345:74:1;;;44297:32:0::1;::::0;333:2:1;318:18;44297:32:0::1;;;;;;;44173:163:::0;:::o;45741:1445::-;45917:33;45953:55;45996:11;;45953:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;45953:42:0;;-1:-1:-1;;;45953:55:0:i;:::-;45917:91;;46018:21;46042:30;46060:4;46066:5;;46042:17;:30::i;:::-;46082:26;;;;:11;:26;;;;;:39;;;;46111:10;46082:39;;;46166:12;;;;46018:54;;-1:-1:-1;46082:26:0;46166:30;;:28;:30::i;:::-;46132:64;;46223:14;:25;;;46210:9;:38;46206:151;;46320:25;;;;46271:75;;;;;46309:9;46271:75;;;13504:25:1;13545:18;;;13538:34;;;;13477:18;;46271:75:0;13330:248:1;46206:151:0;46518:23;;:34;-1:-1:-1;46514:74:0;;;46565:23;;;-1:-1:-1;46514:74:0;46754:16;;;;46712:71;;;46789:8;46806:9;46843:4;:15;;;46880:4;:14;;;46917:4;:12;;;46955:4;:15;;;46993:4;:12;;;46712:304;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;47103:4;:15;;;47031:148;;47089:4;:12;;;47074:13;47031:148;47120:4;:15;;;47137:4;:14;;;47153:4;:16;;;47031:148;;;;;;;14317:25:1;;;14373:2;14358:18;;14351:34;;;;14416:2;14401:18;;14394:34;14305:2;14290:18;;14115:319;47031:148:0;;;;;;;;45907:1279;;;45741:1445;;;;;:::o;23127:101::-;22365:13;:11;:13::i;:::-;23191:30:::1;23218:1;23191:18;:30::i;:::-;23127:101::o:0;48992:872::-;49235:11;49262:31;49282:10;49262:19;:31::i;:::-;;49371:25;:7;;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;49371:23:0;;-1:-1:-1;;;49371:25:0:i;:::-;-1:-1:-1;49458:69:0;;;;;:45;49472:13;49458:45;;;;:69;;49504:10;;49516;;;;49458:69;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;49452:75;-1:-1:-1;49603:33:0;;;;49599:259;;49652:19;49674:64;49711:7;49727:10;49674:36;:64::i;:::-;49759:88;;;;;49652:86;;-1:-1:-1;49759:54:0;;;;;;:88;;49814:10;;49652:86;;49839:7;;;;49759:88;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;49752:95;;;;:::i;:::-;;;49638:220;49599:259;48992:872;;;;;;;;;:::o;51064:147::-;51149:12;51180:24;:4;:22;:24::i;:::-;51173:31;51064:147;-1:-1:-1;;51064:147:0:o;45069:508::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;10236:22:0;;;45475:95;45491:10;10236:22;45520:19;45541:10;;45553:7;;45562;;45475:15;:95::i;:::-;45468:102;45069:508;-1:-1:-1;;;;;;;;;;;45069:508:0:o;47232:524::-;47302:15;47367:26;;;:11;:26;;;;;;47302:15;;47367:26;;;47403:108;;47452:48;;;;;;;;4494:25:1;;;4467:18;;47452:48:0;4348:177:1;47403:108:0;47520:18;47552:13;47567:8;47541:35;;;;;;;;16756:25:1;;;16829:42;16817:55;16812:2;16797:18;;16790:83;16744:2;16729:18;;16582:297;47541:35:0;;;;;;;-1:-1:-1;;47541:35:0;;;;;;;47650:16;;47541:35;47650:16;;;47610:57;;;;;;4494:25:1;47541:35:0;-1:-1:-1;47624:13:0;47610:39;;;;;4467:18:1;;47610:57:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;47682:67;;375:42:1;363:55;;345:74;;47586:81:0;;-1:-1:-1;47586:81:0;-1:-1:-1;47682:67:0;;;;47586:81;;47704:13;;47682:67;;333:2:1;318:18;47682:67:0;;;;;;;47338:418;;47232:524;;;:::o;44598:426::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;44929:88:0;44945:10;44957:8;44967:19;44988:10;;45000:7;;45009;;44929:15;:88::i;:::-;44922:95;44598:426;-1:-1:-1;;;;;;;;;;44598:426:0:o;49910:236::-;49975:7;50009:13;49998:7;:24;49994:107;;50045:45;;;;;;;;4494:25:1;;;4467:18;;50045:45:0;4348:177:1;49994:107:0;-1:-1:-1;50117:22:0;;;;:13;:22;;;;;;;49910:236::o;50843:149::-;-1:-1:-1;;;;;;;;;;;;;;;;;50953:32:0;:14;:30;:32::i;23377:215::-;22365:13;:11;:13::i;:::-;23461:22:::1;::::0;::::1;23457:91;;23506:31;::::0;::::1;::::0;;23534:1:::1;23506:31;::::0;::::1;345:74:1::0;318:18;;23506:31:0::1;199:226:1::0;23457:91:0::1;23557:28;23576:8;23557:18;:28::i;:::-;23377:215:::0;:::o;44381:172::-;22365:13;:11;:13::i;:::-;44468:22:::1;::::0;;;:13:::1;:22;::::0;;;;;;;;:31;;;44514:32;;13504:25:1;;;13545:18;;;13538:34;;;44514:32:0::1;::::0;13477:18:1;44514:32:0::1;;;;;;;44381:172:::0;;:::o;48537:235::-;48607:7;48626:33;48662:53;48705:9;;48662:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;48662:42:0;;-1:-1:-1;;;48662:53:0:i;:::-;48626:89;;48732:11;:33;48744:20;:4;:18;:20::i;:::-;48732:33;;;;;;;;;;;-1:-1:-1;48732:33:0;;;;;48537:235;-1:-1:-1;;;;48537:235:0:o;25290:174::-;25364:28;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;25364:28:0;25422:9;25411:46;;;;;;;;;;;;:::i;19974:599::-;-1:-1:-1;;;;;;;;;;;;;;;;;20069:14:0;20086:27;:4;:25;:27::i;:::-;20069:44;-1:-1:-1;19749:1:0;20127:20;;;;20123:95;;;20170:37;;;;;19362:6:1;19350:19;;20170:37:0;;;19332:38:1;19305:18;;20170:37:0;19188:188:1;20123:95:0;20525:27;:4;:25;:27::i;:::-;20514:52;;;;;;;;;;;;:::i;:::-;20507:59;19974:599;-1:-1:-1;;;19974:599:0:o;55007:1563::-;55164:21;55201:20;55224:36;55244:4;:15;;;55224:19;:36::i;:::-;55201:59;;55293:13;55274:4;:15;;;:32;55270:126;;55369:4;:15;;;55329:56;;;;;;;;;4494:25:1;;4482:2;4467:18;;4348:177;55270:126:0;55421:20;:4;:18;:20::i;:::-;55493:1;55455:26;;;:11;:26;;;;;;55405:36;;-1:-1:-1;55455:40:0;:26;:40;55451:130;;55518:52;;;;;;;;4494:25:1;;;4467:18;;55518:52:0;4348:177:1;55451:130:0;55654:30;55687:218;;;;;;;;55729:4;:15;;;55687:218;;;;55767:4;:12;;;55687:218;;;;55805:4;:15;;;55687:218;;;;;;55845:12;55687:218;;;;55881:13;55687:218;;;55654:251;;55916:29;55947:35;56013:44;56040:4;:16;;;10382:1;10272:121;56013:44;55998:79;;;:81;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;55998:81:0;;;;;;;;;;;;:::i;:::-;55915:164;;;;56089:28;56120:36;:16;:34;:36::i;:::-;56170:27;;56089:67;;-1:-1:-1;56170:27:0;:32;56166:113;;56225:43;;;;;;;;;;;;;;56166:113;56288:17;56308:91;56336:18;56356:7;56365:5;;56372:9;:26;;;56308:27;:91::i;:::-;56425:27;;56288:111;;-1:-1:-1;56413:39:0;;56409:155;;;56525:27;;56475:78;;;;;;;56514:9;;56475:78;;13504:25:1;;;13560:2;13545:18;;13538:34;13492:2;13477:18;;13330:248;56409:155:0;55191:1379;;;;;;55007:1563;;;;;:::o;22630:162::-;22518:7;22544:6;22689:23;22544:6;14998:10;22689:23;22685:101;;22735:40;;;;;14998:10;22735:40;;;345:74:1;318:18;;22735:40:0;199:226:1;23746:187:0;23819:16;23838:6;;;23854:17;;;;;;;;;;23886:40;;23838:6;;;;;;;23886:40;;23819:16;23886:40;23809:124;23746:187;:::o;56661:368::-;56730:20;56777:13;56766:7;:24;56762:107;;56813:45;;;;;;;;4494:25:1;;;4467:18;;56813:45:0;4348:177:1;56762:107:0;-1:-1:-1;56893:22:0;;;;:13;:22;;;;;;;56929:17;;;56925:98;;56969:43;;;;;;;;4494:25:1;;;4467:18;;56969:43:0;4348:177:1;56925:98:0;56661:368;;;:::o;25470:506::-;25554:7;-1:-1:-1;;10058:2:0;10039:6;;10038:23;-1:-1:-1;;10058:2:0;10039:6;;10038:23;25908:32;;:3;:32;:::i;:::-;:61;;;;:::i;25131:153::-;25223:12;25265:11;25254:23;;;;;;;;:::i;:::-;;;;;;;;;;;;;25247:30;;25131:153;;;:::o;51613:2966::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;51922:31:0;51942:10;51922:19;:31::i;:::-;-1:-1:-1;51979:1:0;51967:13;;;51963:60;;51989:34;;;;;;;;;;;;;;51963:60;52101:25;:7;;:23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;52101:23:0;;-1:-1:-1;;;52101:25:0:i;:::-;-1:-1:-1;52162:69:0;;;;;52136:23;;52162:45;52176:13;52162:45;;;;:69;;52208:10;;52220;;;;52162:69;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;52136:95;;52257:15;52245:9;:27;52241:128;;;52295:63;;;;;52331:9;52295:63;;;13504:25:1;13545:18;;;13538:34;;;13477:18;;52295:63:0;13330:248:1;52241:128:0;52426:13;52412:46;;;:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;52379:4;:12;;52393:4;:15;;52378:82;;;;;;;;;;;;;;52470:33;52506:304;52582:10;52653;52619:8;52686:4;:12;;;52724:4;:15;;;52762:7;;52506:304;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;52792:7;;52506:304;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;52506:50:0;;-1:-1:-1;;;52506:304:0:i;:::-;52470:340;;52841:20;:4;:18;:20::i;:::-;52820:4;:18;;:41;;;;;52991:15;53008:17;53043:13;53029:55;;;53109:15;53139:4;:15;;;53156:4;:18;;;53176:10;;53029:158;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;52990:197;;;;53219:4;:12;;;53208:7;:23;:56;;;;;53249:4;:15;;;53235:29;;:10;:29;;;53208:56;53201:64;;;;:::i;:::-;-1:-1:-1;;53354:9:0;:27;;;;53405:16;;53401:150;;53452:13;;53504:15;;;;;53521:18;;53437:103;;;;;53452:13;;;;;53437:45;;53490:12;;53437:103;;53504:15;;53521:18;53437:103;;13504:25:1;;;13560:2;13545:18;;13538:34;13492:2;13477:18;;13330:248;53437:103:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;53401:150;53639:33;;;;53635:607;;53688:55;;;;53774:10;53817:68;53854:7;53870;53817:36;:68::i;:::-;53918:18;;53688:341;;;;;;;;;;;;;;53918:18;53968:12;;54007:7;;;;53688:341;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;54043:22;54086:19;54068:50;;;:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;54149:13;;54179:15;;;;;54196:18;;54134:97;;;;;;;;23982:25:1;;;;24023:18;;;24016:34;;;;54149:13:0;24086:55:1;;;24066:18;;;24059:83;54043:77:0;;-1:-1:-1;54149:13:0;;;54134:44;;23955:18:1;;54134:97:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;53674:568;53635:607;54353:4;:15;;;54256:316;;54327:4;:12;;;54295:4;:18;;;54256:316;54382:4;:15;;;54411:4;:14;;;54439:4;:16;;;54469:15;54498:12;54524:4;:12;;;54550:4;:12;;;54256:316;;;;;;;;;;;;:::i;:::-;;;;;;;;51912:2667;;;51613:2966;;;;;;;;;;;:::o;25982:155::-;26070:7;26117:11;26106:23;;;;;;;;:::i;:::-;;;;;;;;;;;;;26096:34;;;;;;26089:41;;25982:155;;;:::o;12395:496::-;12479:14;10671:1;12509:16;:23;:40;12505:122;;;12599:16;12572:44;;;;;;;;;;;:::i;12505:122::-;-1:-1:-1;12868:4:0;12846:27;12840:34;12835:3;12831:44;;12395:496::o;13205:1053::-;13289:20;10671:1;13325:16;:23;:40;13321:122;;;13415:16;13388:44;;;;;;;;;;;:::i;13321:122::-;13601:23;;:40;;;13671:17;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;13671:17:0;;13661:27;;13812:8;14148:6;14141:4;14132:7;14128:18;14120:6;14113:4;14095:16;14091:27;14085:4;14078:5;14067:88;14060:95;;14179:3;14174:78;;14205:36;;;;;;;;;;;;;;14174:78;13311:947;;13205:1053;;;:::o;15734:610::-;-1:-1:-1;;;;;;;;;;;;;;;;;15833:14:0;15850:27;:4;:25;:27::i;:::-;15833:44;-1:-1:-1;15499:1:0;15891:23;;;;15887:100;;;15937:39;;;;;19362:6:1;19350:19;;15937:39:0;;;19332:38:1;19305:18;;15937:39:0;19188:188:1;57542:730:0;57782:26;;57824:442;57848:15;:22;57844:1;:26;57824:442;;;57891:19;57927:13;57913:46;;;57960:15;57976:1;57960:18;;;;;;;;:::i;:::-;;;;;;;57980:7;57989:5;;57913:82;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;57891:104;-1:-1:-1;58133:16:0;;;;;:68;;-1:-1:-1;58186:15:0;58153:30;58167:16;58153:11;:30;:::i;:::-;:48;58133:68;58129:127;;;58221:20;;;:::i;:::-;;;58129:127;-1:-1:-1;57872:3:0;;;:::i;:::-;;;57824:442;;;;57542:730;;;;;;;:::o;24437:688::-;24721:40;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24721:40:0;24784:334;;;;;;;;24832:13;24784:334;;;;24870:37;24897:9;10236:22;;;10139:127;24870:37;24784:334;;;;24933:10;24784:334;;;;24970:11;24784:334;;;;25004:7;24784:334;;;;25037:10;24784:334;;;;;;25070:7;24784:334;;;;25100:7;24784:334;;;24777:341;;24437:688;;;;;;;;;:::o;14:180:1:-;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;-1:-1:-1;165:23:1;;14:180;-1:-1:-1;14:180:1:o;430:347::-;481:8;491:6;545:3;538:4;530:6;526:17;522:27;512:55;;563:1;560;553:12;512:55;-1:-1:-1;586:20:1;;629:18;618:30;;615:50;;;661:1;658;651:12;615:50;698:4;690:6;686:17;674:29;;750:3;743:4;734:6;726;722:19;718:30;715:39;712:59;;;767:1;764;757:12;712:59;430:347;;;;;:::o;782:367::-;845:8;855:6;909:3;902:4;894:6;890:17;886:27;876:55;;927:1;924;917:12;876:55;-1:-1:-1;950:20:1;;993:18;982:30;;979:50;;;1025:1;1022;1015:12;979:50;1062:4;1054:6;1050:17;1038:29;;1122:3;1115:4;1105:6;1102:1;1098:14;1090:6;1086:27;1082:38;1079:47;1076:67;;;1139:1;1136;1129:12;1154:745;1260:6;1268;1276;1284;1337:2;1325:9;1316:7;1312:23;1308:32;1305:52;;;1353:1;1350;1343:12;1305:52;1393:9;1380:23;1422:18;1463:2;1455:6;1452:14;1449:34;;;1479:1;1476;1469:12;1449:34;1518:58;1568:7;1559:6;1548:9;1544:22;1518:58;:::i;:::-;1595:8;;-1:-1:-1;1492:84:1;-1:-1:-1;1683:2:1;1668:18;;1655:32;;-1:-1:-1;1699:16:1;;;1696:36;;;1728:1;1725;1718:12;1696:36;;1767:72;1831:7;1820:8;1809:9;1805:24;1767:72;:::i;:::-;1154:745;;;;-1:-1:-1;1858:8:1;-1:-1:-1;;;;1154:745:1:o;2096:154::-;2182:42;2175:5;2171:54;2164:5;2161:65;2151:93;;2240:1;2237;2230:12;2255:247;2314:6;2367:2;2355:9;2346:7;2342:23;2338:32;2335:52;;;2383:1;2380;2373:12;2335:52;2422:9;2409:23;2441:31;2466:5;2441:31;:::i;2507:813::-;2622:6;2630;2638;2646;2654;2707:2;2695:9;2686:7;2682:23;2678:32;2675:52;;;2723:1;2720;2713:12;2675:52;2759:9;2746:23;2736:33;;2820:2;2809:9;2805:18;2792:32;2843:18;2884:2;2876:6;2873:14;2870:34;;;2900:1;2897;2890:12;2870:34;2939:58;2989:7;2980:6;2969:9;2965:22;2939:58;:::i;:::-;3016:8;;-1:-1:-1;2913:84:1;-1:-1:-1;3104:2:1;3089:18;;3076:32;;-1:-1:-1;3120:16:1;;;3117:36;;;3149:1;3146;3139:12;3117:36;;3188:72;3252:7;3241:8;3230:9;3226:24;3188:72;:::i;:::-;2507:813;;;;-1:-1:-1;2507:813:1;;-1:-1:-1;3279:8:1;;3162:98;2507:813;-1:-1:-1;;;2507:813:1:o;3325:1018::-;3458:6;3466;3474;3482;3490;3498;3506;3559:3;3547:9;3538:7;3534:23;3530:33;3527:53;;;3576:1;3573;3566:12;3527:53;3612:9;3599:23;3589:33;;3672:2;3661:9;3657:18;3644:32;3685:31;3710:5;3685:31;:::i;:::-;3735:5;-1:-1:-1;3791:2:1;3776:18;;3763:32;3814:18;3844:14;;;3841:34;;;3871:1;3868;3861:12;3841:34;3910:70;3972:7;3963:6;3952:9;3948:22;3910:70;:::i;:::-;3999:8;;-1:-1:-1;3884:96:1;-1:-1:-1;4087:2:1;4072:18;;4059:32;;-1:-1:-1;4103:16:1;;;4100:36;;;4132:1;4129;4122:12;4100:36;;4171:60;4223:7;4212:8;4201:9;4197:24;4171:60;:::i;:::-;3325:1018;;;;-1:-1:-1;3325:1018:1;;;;;;4332:3;4317:19;;;4304:33;;3325:1018;-1:-1:-1;;;;3325:1018:1:o;4530:184::-;4582:77;4579:1;4572:88;4679:4;4676:1;4669:15;4703:4;4700:1;4693:15;4719:255;4791:2;4785:9;4833:6;4821:19;;4870:18;4855:34;;4891:22;;;4852:62;4849:88;;;4917:18;;:::i;:::-;4953:2;4946:22;4719:255;:::o;4979:334::-;5050:2;5044:9;5106:2;5096:13;;-1:-1:-1;;5092:86:1;5080:99;;5209:18;5194:34;;5230:22;;;5191:62;5188:88;;;5256:18;;:::i;:::-;5292:2;5285:22;4979:334;;-1:-1:-1;4979:334:1:o;5318:129::-;5403:18;5396:5;5392:30;5385:5;5382:41;5372:69;;5437:1;5434;5427:12;5452:132;5519:20;;5548:30;5519:20;5548:30;:::i;5589:245::-;5637:4;5670:18;5662:6;5659:30;5656:56;;;5692:18;;:::i;:::-;-1:-1:-1;5749:2:1;5737:15;-1:-1:-1;;5733:88:1;5823:4;5729:99;;5589:245::o;5839:462::-;5881:5;5934:3;5927:4;5919:6;5915:17;5911:27;5901:55;;5952:1;5949;5942:12;5901:55;5988:6;5975:20;6019:48;6035:31;6063:2;6035:31;:::i;:::-;6019:48;:::i;:::-;6092:2;6083:7;6076:19;6138:3;6131:4;6126:2;6118:6;6114:15;6110:26;6107:35;6104:55;;;6155:1;6152;6145:12;6104:55;6220:2;6213:4;6205:6;6201:17;6194:4;6185:7;6181:18;6168:55;6268:1;6243:16;;;6261:4;6239:27;6232:38;;;;6247:7;5839:462;-1:-1:-1;;;5839:462:1:o;6306:1156::-;6403:6;6456:2;6444:9;6435:7;6431:23;6427:32;6424:52;;;6472:1;6469;6462:12;6424:52;6512:9;6499:23;6541:18;6582:2;6574:6;6571:14;6568:34;;;6598:1;6595;6588:12;6568:34;6621:22;;;;6677:6;6659:16;;;6655:29;6652:49;;;6697:1;6694;6687:12;6652:49;6723:22;;:::i;:::-;6781:2;6768:16;6761:5;6754:31;6838:2;6834;6830:11;6817:25;6812:2;6805:5;6801:14;6794:49;6896:2;6892;6888:11;6875:25;6870:2;6863:5;6859:14;6852:49;6954:2;6950;6946:11;6933:25;6928:2;6921:5;6917:14;6910:49;7013:3;7009:2;7005:12;6992:26;6986:3;6979:5;6975:15;6968:51;7052:31;7078:3;7074:2;7070:12;7052:31;:::i;:::-;7046:3;7039:5;7035:15;7028:56;7130:3;7126:2;7122:12;7109:26;7160:2;7150:8;7147:16;7144:36;;;7176:1;7173;7166:12;7144:36;7213:44;7249:7;7238:8;7234:2;7230:17;7213:44;:::i;:::-;7207:3;7200:5;7196:15;7189:69;;7304:3;7300:2;7296:12;7283:26;7334:2;7324:8;7321:16;7318:36;;;7350:1;7347;7340:12;7318:36;7387:44;7423:7;7412:8;7408:2;7404:17;7387:44;:::i;:::-;7381:3;7370:15;;7363:69;-1:-1:-1;7374:5:1;6306:1156;-1:-1:-1;;;;;6306:1156:1:o;7467:250::-;7552:1;7562:113;7576:6;7573:1;7570:13;7562:113;;;7652:11;;;7646:18;7633:11;;;7626:39;7598:2;7591:10;7562:113;;;-1:-1:-1;;7709:1:1;7691:16;;7684:27;7467:250::o;7722:329::-;7763:3;7801:5;7795:12;7828:6;7823:3;7816:19;7844:76;7913:6;7906:4;7901:3;7897:14;7890:4;7883:5;7879:16;7844:76;:::i;:::-;7965:2;7953:15;-1:-1:-1;;7949:88:1;7940:98;;;;8040:4;7936:109;;7722:329;-1:-1:-1;;7722:329:1:o;8056:217::-;8203:2;8192:9;8185:21;8166:4;8223:44;8263:2;8252:9;8248:18;8240:6;8223:44;:::i;8278:1379::-;8431:6;8439;8447;8455;8463;8471;8479;8487;8495;8548:3;8536:9;8527:7;8523:23;8519:33;8516:53;;;8565:1;8562;8555:12;8516:53;8601:9;8588:23;8578:33;;8661:2;8650:9;8646:18;8633:32;8674:31;8699:5;8674:31;:::i;:::-;8724:5;-1:-1:-1;8781:2:1;8766:18;;8753:32;8794:33;8753:32;8794:33;:::i;:::-;8846:7;-1:-1:-1;8904:2:1;8889:18;;8876:32;8927:18;8957:14;;;8954:34;;;8984:1;8981;8974:12;8954:34;9023:70;9085:7;9076:6;9065:9;9061:22;9023:70;:::i;:::-;9112:8;;-1:-1:-1;8997:96:1;-1:-1:-1;9200:3:1;9185:19;;9172:33;;-1:-1:-1;9217:16:1;;;9214:36;;;9246:1;9243;9236:12;9214:36;9285:60;9337:7;9326:8;9315:9;9311:24;9285:60;:::i;:::-;9364:8;;-1:-1:-1;9259:86:1;-1:-1:-1;9452:3:1;9437:19;;9424:33;;-1:-1:-1;9469:16:1;;;9466:36;;;9498:1;9495;9488:12;9466:36;;9537:60;9589:7;9578:8;9567:9;9563:24;9537:60;:::i;:::-;9511:86;;9616:8;9606:18;;;9643:8;9633:18;;;8278:1379;;;;;;;;;;;:::o;10541:1306::-;10694:6;10702;10710;10718;10726;10734;10742;10750;10758;10811:3;10799:9;10790:7;10786:23;10782:33;10779:53;;;10828:1;10825;10818:12;10779:53;10864:9;10851:23;10841:33;;10921:2;10910:9;10906:18;10893:32;10883:42;;10975:2;10964:9;10960:18;10947:32;10988:31;11013:5;10988:31;:::i;12034:320::-;12102:6;12155:2;12143:9;12134:7;12130:23;12126:32;12123:52;;;12171:1;12168;12161:12;12123:52;12211:9;12198:23;12244:18;12236:6;12233:30;12230:50;;;12276:1;12273;12266:12;12230:50;12299:49;12340:7;12331:6;12320:9;12316:22;12299:49;:::i;:::-;12289:59;12034:320;-1:-1:-1;;;;12034:320:1:o;12663:248::-;12731:6;12739;12792:2;12780:9;12771:7;12767:23;12763:32;12760:52;;;12808:1;12805;12798:12;12760:52;-1:-1:-1;;12831:23:1;;;12901:2;12886:18;;;12873:32;;-1:-1:-1;12663:248:1:o;12916:409::-;12986:6;12994;13047:2;13035:9;13026:7;13022:23;13018:32;13015:52;;;13063:1;13060;13053:12;13015:52;13103:9;13090:23;13136:18;13128:6;13125:30;13122:50;;;13168:1;13165;13158:12;13122:50;13207:58;13257:7;13248:6;13237:9;13233:22;13207:58;:::i;:::-;13284:8;;13181:84;;-1:-1:-1;12916:409:1;-1:-1:-1;;;;12916:409:1:o;13583:527::-;13840:6;13829:9;13822:25;13883:6;13878:2;13867:9;13863:18;13856:34;13926:6;13921:2;13910:9;13906:18;13899:34;13981:18;13973:6;13969:31;13964:2;13953:9;13949:18;13942:59;14038:3;14032;14021:9;14017:19;14010:32;13803:4;14059:45;14099:3;14088:9;14084:19;14076:6;14059:45;:::i;14439:545::-;14539:6;14534:3;14527:19;14509:3;14565:4;14594:2;14589:3;14585:12;14578:19;;14620:5;14643:1;14653:306;14667:6;14664:1;14661:13;14653:306;;;14744:6;14731:20;14764:33;14789:7;14764:33;:::i;:::-;14835:42;14822:56;14810:69;;14899:12;;;;14934:15;;;;14689:1;14682:9;14653:306;;;-1:-1:-1;14975:3:1;;14439:545;-1:-1:-1;;;;;14439:545:1:o;14989:359::-;15206:6;15195:9;15188:25;15249:2;15244;15233:9;15229:18;15222:30;15169:4;15269:73;15338:2;15327:9;15323:18;15315:6;15307;15269:73;:::i;:::-;15261:81;14989:359;-1:-1:-1;;;;;14989:359:1:o;15353:184::-;15423:6;15476:2;15464:9;15455:7;15451:23;15447:32;15444:52;;;15492:1;15489;15482:12;15444:52;-1:-1:-1;15515:16:1;;15353:184;-1:-1:-1;15353:184:1:o;15542:325::-;15630:6;15625:3;15618:19;15682:6;15675:5;15668:4;15663:3;15659:14;15646:43;;15734:1;15727:4;15718:6;15713:3;15709:16;15705:27;15698:38;15600:3;15856:4;-1:-1:-1;;15781:2:1;15773:6;15769:15;15765:88;15760:3;15756:98;15752:109;15745:116;;15542:325;;;;:::o;15872:386::-;16085:6;16074:9;16067:25;16128:6;16123:2;16112:9;16108:18;16101:34;16171:2;16166;16155:9;16151:18;16144:30;16048:4;16191:61;16248:2;16237:9;16233:18;16225:6;16217;16191:61;:::i;:::-;16183:69;15872:386;-1:-1:-1;;;;;;15872:386:1:o;16263:184::-;16315:77;16312:1;16305:88;16412:4;16409:1;16402:15;16436:4;16433:1;16426:15;16452:125;16517:9;;;16538:10;;;16535:36;;;16551:18;;:::i;16884:136::-;16962:13;;16984:30;16962:13;16984:30;:::i;17025:310::-;17103:6;17111;17164:2;17152:9;17143:7;17139:23;17135:32;17132:52;;;17180:1;17177;17170:12;17132:52;17209:9;17203:16;17193:26;;17262:2;17251:9;17247:18;17241:25;17275:30;17299:5;17275:30;:::i;:::-;17324:5;17314:15;;;17025:310;;;;;:::o;17593:441::-;17646:5;17699:3;17692:4;17684:6;17680:17;17676:27;17666:55;;17717:1;17714;17707:12;17666:55;17746:6;17740:13;17777:48;17793:31;17821:2;17793:31;:::i;17777:48::-;17850:2;17841:7;17834:19;17896:3;17889:4;17884:2;17876:6;17872:15;17868:26;17865:35;17862:55;;;17913:1;17910;17903:12;17862:55;17926:77;18000:2;17993:4;17984:7;17980:18;17973:4;17965:6;17961:17;17926:77;:::i;18039:1144::-;18147:6;18200:2;18188:9;18179:7;18175:23;18171:32;18168:52;;;18216:1;18213;18206:12;18168:52;18249:9;18243:16;18278:18;18319:2;18311:6;18308:14;18305:34;;;18335:1;18332;18325:12;18305:34;18358:22;;;;18414:6;18396:16;;;18392:29;18389:49;;;18434:1;18431;18424:12;18389:49;18460:22;;:::i;:::-;18511:2;18505:9;18498:5;18491:24;18561:2;18557;18553:11;18547:18;18542:2;18535:5;18531:14;18524:42;18612:2;18608;18604:11;18598:18;18593:2;18586:5;18582:14;18575:42;18663:2;18659;18655:11;18649:18;18644:2;18637:5;18633:14;18626:42;18715:3;18711:2;18707:12;18701:19;18695:3;18688:5;18684:15;18677:44;18754:42;18791:3;18787:2;18783:12;18754:42;:::i;:::-;18748:3;18741:5;18737:15;18730:67;18836:3;18832:2;18828:12;18822:19;18866:2;18856:8;18853:16;18850:36;;;18882:1;18879;18872:12;18850:36;18919:55;18966:7;18955:8;18951:2;18947:17;18919:55;:::i;:::-;18913:3;18906:5;18902:15;18895:80;;19014:3;19010:2;19006:12;19000:19;19044:2;19034:8;19031:16;19028:36;;;19060:1;19057;19050:12;19028:36;19097:55;19144:7;19133:8;19129:2;19125:17;19097:55;:::i;19381:475::-;19448:5;19496:4;19484:9;19479:3;19475:19;19471:30;19468:50;;;19514:1;19511;19504:12;19468:50;19547:4;19541:11;19591:4;19583:6;19579:17;19662:6;19650:10;19647:22;19626:18;19614:10;19611:34;19608:62;19605:88;;;19673:18;;:::i;:::-;19709:4;19702:24;19774:16;;19759:32;;19845:2;19830:18;;;19824:25;19807:15;;;19800:50;;;;-1:-1:-1;19744:6:1;19381:475;-1:-1:-1;19381:475:1:o;19861:252::-;19957:6;20010:2;19998:9;19989:7;19985:23;19981:32;19978:52;;;20026:1;20023;20016:12;19978:52;20049:58;20099:7;20088:9;20049:58;:::i;20118:1213::-;20231:6;20239;20292:2;20280:9;20271:7;20267:23;20263:32;20260:52;;;20308:1;20305;20298:12;20260:52;20341:9;20335:16;20370:18;20411:2;20403:6;20400:14;20397:34;;;20427:1;20424;20417:12;20397:34;20450:60;20502:7;20493:6;20482:9;20478:22;20450:60;:::i;:::-;20440:70;;20529:2;20519:12;;20577:2;20566:9;20562:18;20556:25;20606:2;20596:8;20593:16;20590:36;;;20622:1;20619;20612:12;20590:36;20645:24;;20700:4;20692:13;;20688:27;-1:-1:-1;20678:55:1;;20729:1;20726;20719:12;20678:55;20758:2;20752:9;20780:2;20776;20773:10;20770:36;;;20786:18;;:::i;:::-;20832:2;20829:1;20825:10;20815:20;;20855:28;20879:2;20875;20871:11;20855:28;:::i;:::-;20917:15;;;20987:11;;;20983:20;;;20948:12;;;;21015:19;;;21012:39;;;21047:1;21044;21037:12;21012:39;21071:11;;;;21091:210;21107:6;21102:3;21099:15;21091:210;;;21180:3;21174:10;21161:23;;21197:31;21222:5;21197:31;:::i;:::-;21241:18;;;21124:12;;;;21279;;;;21091:210;;;21320:5;21310:15;;;;;;;;20118:1213;;;;;:::o;21336:1023::-;21541:2;21530:9;21523:21;21586:6;21580:13;21575:2;21564:9;21560:18;21553:41;21648:2;21640:6;21636:15;21630:22;21625:2;21614:9;21610:18;21603:50;21707:2;21699:6;21695:15;21689:22;21684:2;21673:9;21669:18;21662:50;21767:2;21759:6;21755:15;21749:22;21743:3;21732:9;21728:19;21721:51;21827:3;21819:6;21815:16;21809:23;21803:3;21792:9;21788:19;21781:52;21899:18;21892:3;21884:6;21880:16;21874:23;21870:48;21864:3;21853:9;21849:19;21842:77;21504:4;21966:3;21958:6;21954:16;21948:23;21990:6;22033:2;22027:3;22016:9;22012:19;22005:31;22059:51;22105:3;22094:9;22090:19;22076:12;22059:51;:::i;:::-;22045:65;;22159:3;22151:6;22147:16;22141:23;-1:-1:-1;;22216:9:1;22208:6;22204:22;22200:95;22195:2;22184:9;22180:18;22173:123;22313:40;22346:6;22330:14;22313:40;:::i;22364:430::-;22609:6;22598:9;22591:25;22652:6;22647:2;22636:9;22632:18;22625:34;22695:2;22690;22679:9;22675:18;22668:30;22572:4;22715:73;22784:2;22773:9;22769:18;22761:6;22753;22715:73;:::i;22799:184::-;22851:77;22848:1;22841:88;22948:4;22945:1;22938:15;22972:4;22969:1;22962:15;22988:531;23257:6;23246:9;23239:25;23300:6;23295:2;23284:9;23280:18;23273:34;23343:6;23338:2;23327:9;23323:18;23316:34;23386:6;23381:2;23370:9;23366:18;23359:34;23430:3;23424;23413:9;23409:19;23402:32;23220:4;23451:62;23508:3;23497:9;23493:19;23485:6;23477;23451:62;:::i;:::-;23443:70;22988:531;-1:-1:-1;;;;;;;;22988:531:1:o;23524:251::-;23594:6;23647:2;23635:9;23626:7;23622:23;23618:32;23615:52;;;23663:1;23660;23653:12;23615:52;23695:9;23689:16;23714:31;23739:5;23714:31;:::i;24153:737::-;24486:6;24475:9;24468:25;24529:6;24524:2;24513:9;24509:18;24502:34;24572:6;24567:2;24556:9;24552:18;24545:34;24615:6;24610:2;24599:9;24595:18;24588:34;24659:6;24653:3;24642:9;24638:19;24631:35;24703:3;24697;24686:9;24682:19;24675:32;24449:4;24730:45;24770:3;24759:9;24755:19;24747:6;24730:45;:::i;:::-;24824:9;24816:6;24812:22;24806:3;24795:9;24791:19;24784:51;24852:32;24877:6;24869;24852:32;:::i;25154:184::-;25206:77;25203:1;25196:88;25303:4;25300:1;25293:15;25327:4;25324:1;25317:15;25343:1041;25664:42;25656:6;25652:55;25641:9;25634:74;25750:6;25744:13;25739:2;25728:9;25724:18;25717:41;25812:2;25804:6;25800:15;25794:22;25789:2;25778:9;25774:18;25767:50;25881:18;25875:2;25867:6;25863:15;25857:22;25853:47;25848:2;25837:9;25833:18;25826:75;25956:2;25948:6;25944:15;25938:22;25932:3;25921:9;25917:19;25910:51;26016:3;26008:6;26004:16;25998:23;25992:3;25981:9;25977:19;25970:52;26059:3;26053;26042:9;26038:19;26031:32;26100:6;26094:3;26083:9;26079:19;26072:35;25615:4;26126:3;26152:66;26144:6;26141:78;26138:98;;;26232:1;26229;26222:12;26138:98;26266:6;26263:1;26259:14;26323:6;26315;26310:2;26299:9;26295:18;26282:48;26351:22;;;;26347:31;;;;25343:1041;-1:-1:-1;;;;;25343:1041:1:o;26389:195::-;26428:3;26459:66;26452:5;26449:77;26446:103;;26529:18;;:::i;:::-;-1:-1:-1;26576:1:1;26565:13;;26389:195::o","abiDefinition":[{"inputs":[{"internalType":"address","name":"interchainDB","type":"address"},{"internalType":"address","name":"owner_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"AppConfigLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__FeeAmountTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__IncorrectDstChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__IncorrectMsgValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NoLinkedClient","type":"error"},{"inputs":[{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"InterchainClientV1__NotEVMClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__NotEnoughResponses","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NotRemoteChainId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxAlreadyExecuted","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxNotExecuted","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroReceiver","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroRequiredResponses","type":"error"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionFees","type":"address"}],"name":"ExecutionFeesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"address","name":"executor","type":"address"}],"name":"ExecutionProofWritten","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"}],"name":"InterchainTransactionReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"dstChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"verificationFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"options","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"InterchainTransactionSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"LinkedClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"INTERCHAIN_DB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedOptions","type":"bytes"}],"name":"decodeOptions","outputs":[{"components":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"}],"internalType":"struct OptionsV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"dstReceiver","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct InterchainTransaction","name":"icTx","type":"tuple"}],"name":"encodeTransaction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"executionFees","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedTx","type":"bytes"}],"name":"getExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getExecutorById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"uint256","name":"messageLen","type":"uint256"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClient","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClientEVM","outputs":[{"internalType":"address","name":"linkedClientEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"interchainExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSend","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSendEVM","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"encodedTx","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"isExecutable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionFees_","type":"address"}],"name":"setExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"setLinkedClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"writeExecutionProof","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"INTERCHAIN_DB()":{"notice":"Address of the InterchainDB contract, set at the time of deployment."},"decodeOptions(bytes)":{"notice":"Decodes the encoded options data into a OptionsV1 struct."},"encodeTransaction((uint256,bytes32,uint256,bytes32,uint256,uint64,bytes,bytes))":{"notice":"Encodes the transaction data into a bytes format."},"executionFees()":{"notice":"Address of the contract that handles execution fees. Can be updated by the owner."},"getExecutorById(bytes32)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getInterchainFee(uint256,address,address[],bytes,uint256)":{"notice":"Returns the fee for sending an Interchain message."},"getLinkedClient(uint256)":{"notice":"Returns the address of the linked client (as bytes32) for a specific chain ID."},"getLinkedClientEVM(uint256)":{"notice":"Returns the EVM address of the linked client for a specific chain ID."},"interchainExecute(uint256,bytes,bytes32[])":{"notice":"Executes a transaction that has been sent via the Interchain."},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"notice":"Sends a message to another chain via the Interchain Communication Protocol."},"setExecutionFees(address)":{"notice":"Sets the address of the ExecutionFees contract."},"setLinkedClient(uint256,bytes32)":{"notice":"Sets the linked client for a specific chain ID."},"writeExecutionProof(bytes32)":{"notice":"Writes the proof of execution for a transaction into the InterchainDB."}},"version":1},"developerDoc":{"details":"Implements the operations of the Interchain Execution Layer.","errors":{"OwnableInvalidOwner(address)":[{"details":"The owner is not a valid owner account. (eg. `address(0)`)"}],"OwnableUnauthorizedAccount(address)":[{"details":"The caller account is not authorized to perform an operation."}]},"kind":"dev","methods":{"getInterchainFee(uint256,address,address[],bytes,uint256)":{"params":{"dstChainId":"The chain ID of the destination chain.","messageLen":"The length of the message being sent.","options":"Execution options for the message sent, currently gas limit + native gas drop.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."}},"getLinkedClient(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID."},"getLinkedClientEVM(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client."},"interchainExecute(uint256,bytes,bytes32[])":{"details":"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.","params":{"gasLimit":"The gas limit to use for the execution.","proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The transaction data."}},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"details":"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.","params":{"dstChainId":"The chain ID of the destination chain.","message":"The message being sent.","options":"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.","receiver":"The address of the receiver on the destination chain.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."},"returns":{"desc":"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch."}},"owner()":{"details":"Returns the address of the current owner."},"renounceOwnership()":{"details":"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner."},"setExecutionFees(address)":{"details":"Only callable by the contract owner or an authorized account.","params":{"executionFees_":"The address of the ExecutionFees contract."}},"setLinkedClient(uint256,bytes32)":{"details":"Stores the address of the linked client in a mapping with the chain ID as the key.","params":{"chainId":"The chain ID for which the client is being set.","client":"The address of the client being linked."}},"transferOwnership(address)":{"details":"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."},"writeExecutionProof(bytes32)":{"details":"Will revert if the transaction has not been executed.","params":{"transactionId":"The ID of the transaction to write the proof for."},"returns":{"dbNonce":" The database nonce of the batch containing the written proof for transaction.","entryIndex":" The index of the written proof for transaction within the batch."}}},"stateVariables":{"_linkedClient":{"details":"Address of the InterchainClient contract on the remote chain"},"_txExecutor":{"details":"Executor address that completed the transaction. Address(0) if not executed yet."}},"title":"InterchainClientV1","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"interchainDB\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionFees\",\"type\":\"address\"}],\"name\":\"ExecutionFeesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionProofWritten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"}],\"name\":\"InterchainTransactionReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"verificationFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"InterchainTransactionSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"LinkedClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"INTERCHAIN_DB\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedOptions\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"struct OptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"struct InterchainTransaction\",\"name\":\"icTx\",\"type\":\"tuple\"}],\"name\":\"encodeTransaction\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"executionFees\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedClientEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"encodedTx\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implements the operations of the Interchain Execution Layer.\",\"errors\":{\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}]},\"kind\":\"dev\",\"methods\":{\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"messageLen\":\"The length of the message being sent.\",\"options\":\"Execution options for the message sent, currently gas limit + native gas drop.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"}},\"getLinkedClient(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"details\":\"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.\",\"params\":{\"gasLimit\":\"The gas limit to use for the execution.\",\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The transaction data.\"}},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"details\":\"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.\",\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"message\":\"The message being sent.\",\"options\":\"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\",\"receiver\":\"The address of the receiver on the destination chain.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"},\"returns\":{\"desc\":\"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"setExecutionFees(address)\":{\"details\":\"Only callable by the contract owner or an authorized account.\",\"params\":{\"executionFees_\":\"The address of the ExecutionFees contract.\"}},\"setLinkedClient(uint256,bytes32)\":{\"details\":\"Stores the address of the linked client in a mapping with the chain ID as the key.\",\"params\":{\"chainId\":\"The chain ID for which the client is being set.\",\"client\":\"The address of the client being linked.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"writeExecutionProof(bytes32)\":{\"details\":\"Will revert if the transaction has not been executed.\",\"params\":{\"transactionId\":\"The ID of the transaction to write the proof for.\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written proof for transaction.\",\"entryIndex\":\" The index of the written proof for transaction within the batch.\"}}},\"stateVariables\":{\"_linkedClient\":{\"details\":\"Address of the InterchainClient contract on the remote chain\"},\"_txExecutor\":{\"details\":\"Executor address that completed the transaction. Address(0) if not executed yet.\"}},\"title\":\"InterchainClientV1\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"INTERCHAIN_DB()\":{\"notice\":\"Address of the InterchainDB contract, set at the time of deployment.\"},\"decodeOptions(bytes)\":{\"notice\":\"Decodes the encoded options data into a OptionsV1 struct.\"},\"encodeTransaction((uint256,bytes32,uint256,bytes32,uint256,uint64,bytes,bytes))\":{\"notice\":\"Encodes the transaction data into a bytes format.\"},\"executionFees()\":{\"notice\":\"Address of the contract that handles execution fees. Can be updated by the owner.\"},\"getExecutorById(bytes32)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"notice\":\"Returns the fee for sending an Interchain message.\"},\"getLinkedClient(uint256)\":{\"notice\":\"Returns the address of the linked client (as bytes32) for a specific chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"notice\":\"Returns the EVM address of the linked client for a specific chain ID.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"notice\":\"Executes a transaction that has been sent via the Interchain.\"},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"notice\":\"Sends a message to another chain via the Interchain Communication Protocol.\"},\"setExecutionFees(address)\":{\"notice\":\"Sets the address of the ExecutionFees contract.\"},\"setLinkedClient(uint256,bytes32)\":{\"notice\":\"Sets the linked client for a specific chain ID.\"},\"writeExecutionProof(bytes32)\":{\"notice\":\"Writes the proof of execution for a transaction into the InterchainDB.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainClientV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"INTERCHAIN_DB()":"e4c61247","decodeOptions(bytes)":"d5e788a0","encodeTransaction((uint256,bytes32,uint256,bytes32,uint256,uint64,bytes,bytes))":"7c80a90f","executionFees()":"7341eaf9","getExecutor(bytes)":"f92a79ff","getExecutorById(bytes32)":"f1a61fac","getInterchainFee(uint256,address,address[],bytes,uint256)":"7a1277db","getLinkedClient(uint256)":"aa102ec4","getLinkedClientEVM(uint256)":"02172a35","interchainExecute(uint256,bytes,bytes32[])":"53b67d74","interchainSend(uint256,bytes32,address,address[],bytes,bytes)":"98939d28","interchainSendEVM(uint256,address,address,address[],bytes,bytes)":"827f940d","isExecutable(bytes,bytes32[])":"1450c281","owner()":"8da5cb5b","renounceOwnership()":"715018a6","setExecutionFees(address)":"3dc68b87","setLinkedClient(uint256,bytes32)":"f34234c8","transferOwnership(address)":"f2fde38b","writeExecutionProof(bytes32)":"90e81077"}},"solidity/InterchainClientV1.sol:InterchainClientV1Events":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionFees","type":"address"}],"name":"ExecutionFeesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"address","name":"executor","type":"address"}],"name":"ExecutionProofWritten","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"}],"name":"InterchainTransactionReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":true,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"dstChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"srcSender","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"dstReceiver","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"verificationFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"executionFee","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"options","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"InterchainTransactionSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"LinkedClientSet","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionFees\",\"type\":\"address\"}],\"name\":\"ExecutionFeesSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executor\",\"type\":\"address\"}],\"name\":\"ExecutionProofWritten\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"}],\"name\":\"InterchainTransactionReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcSender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"dstReceiver\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"verificationFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"executionFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"InterchainTransactionSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"LinkedClientSet\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainClientV1Events\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:InterchainEntryLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203917cb63c088797953ca5a9e628901ff18f928c4dd98d65e720730f2060d7fc464736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203917cb63c088797953ca5a9e628901ff18f928c4dd98d65e720730f2060d7fc464736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"17492:1633:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;17492:1633:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"17492:1633:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainEntryLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:InterchainTransactionLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212206dfb957f8af4432556f6a35e558409e46ffcbd678d84d534793ce11656a2b2c064736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212206dfb957f8af4432556f6a35e558409e46ffcbd678d84d534793ce11656a2b2c064736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"24366:1773:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;24366:1773:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"24366:1773:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"InterchainTransactionLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:MathLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bf4e55b642cf3dc909dd2e784ef75ee441b3575adfcf9ed35769e404aa89765c64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220bf4e55b642cf3dc909dd2e784ef75ee441b3575adfcf9ed35769e404aa89765c64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"9677:403:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;9677:403:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"9677:403:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"MathLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220356a3cd7f7b16179f69917a934f1eeea5c11dc47e821f09c18ed01cee2e1e7f564736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220356a3cd7f7b16179f69917a934f1eeea5c11dc47e821f09c18ed01cee2e1e7f564736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"19644:1233:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;19644:1233:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"19644:1233:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:Ownable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. The initial owner is set to the address provided by the deployer. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.","errors":{"OwnableInvalidOwner(address)":[{"details":"The owner is not a valid owner account. (eg. `address(0)`)"}],"OwnableUnauthorizedAccount(address)":[{"details":"The caller account is not authorized to perform an operation."}]},"kind":"dev","methods":{"constructor":{"details":"Initializes the contract setting the address provided by the deployer as the initial owner."},"owner()":{"details":"Returns the address of the current owner."},"renounceOwnership()":{"details":"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner."},"transferOwnership(address)":{"details":"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. The initial owner is set to the address provided by the deployer. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.\",\"errors\":{\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}]},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"details\":\"Initializes the contract setting the address provided by the deployer as the initial owner.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"Ownable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{"owner()":"8da5cb5b","renounceOwnership()":"715018a6","transferOwnership(address)":"f2fde38b"}},"solidity/InterchainClientV1.sol:TypeCasts":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220475f9dbd1c5667f87fedc7625fb34e1b9331dd3d56514626f4d3d0b84bdc7c2c64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220475f9dbd1c5667f87fedc7625fb34e1b9331dd3d56514626f4d3d0b84bdc7c2c64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"10115:280:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;10115:280:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"10115:280:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"TypeCasts\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}},"solidity/InterchainClientV1.sol:VersionedPayloadLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122029ddcad98141cdc279da3d603abe13774f75baf3aa583bc9d87d0a906dcc25c864736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122029ddcad98141cdc279da3d603abe13774f75baf3aa583bc9d87d0a906dcc25c864736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/InterchainClientV1Events.sol\n\nabstract contract InterchainClientV1Events {\n event ExecutionFeesSet(address executionFees);\n event LinkedClientSet(uint256 chainId, bytes32 client);\n\n // TODO: figure out indexing\n\n event InterchainTransactionSent(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 dstChainId,\n bytes32 srcSender,\n bytes32 dstReceiver,\n uint256 verificationFee,\n uint256 executionFee,\n bytes options,\n bytes message\n );\n\n event InterchainTransactionReceived(\n bytes32 indexed transactionId,\n uint256 indexed dbNonce,\n uint64 indexed entryIndex,\n uint256 srcChainId,\n bytes32 srcSender,\n bytes32 dstReceiver\n );\n\n event ExecutionProofWritten(\n bytes32 indexed transactionId, uint256 indexed dbNonce, uint64 indexed entryIndex, address executor\n );\n}\n\n// contracts/interfaces/IExecutionFees.sol\n\ninterface IExecutionFees {\n error ExecutionFees__AlreadyRecorded(uint256 dstChainId, bytes32 transactionId, address executor);\n error ExecutionFees__ZeroAddress();\n error ExecutionFees__ZeroAmount();\n\n /// @notice Add the execution fee for a transaction. The attached value will be added to the\n /// rewards for the executor completing the transaction.\n /// Note: this could be used to store the execution fee for a new transaction, or to add more\n /// funds to the execution fee of an existing transaction. Therefore this function is payable,\n /// and does not implement any caller restrictions.\n /// @dev Will revert if the executor is already recorded for the transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to add the execution fee to.\n function addExecutionFee(uint256 dstChainId, bytes32 transactionId) external payable;\n\n /// @notice Record the executor (who completed the transaction) for a transaction,\n /// and update the accumulated rewards for the executor.\n /// @dev Could only be called by the Recorder.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to record the executor for.\n /// @param executor The address of the executor who completed the transaction.\n function recordExecutor(uint256 dstChainId, bytes32 transactionId, address executor) external;\n\n /// @notice Allows the executor to claim their unclaimed rewards.\n /// @dev Will revert if the executor has no unclaimed rewards.\n function claimExecutionFees(address executor) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the accumulated rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function accumulatedRewards(address executor) external view returns (uint256 accumulated);\n\n /// @notice Get the unclaimed rewards for an executor.\n /// @param executor The address of the executor to get the rewards for.\n function unclaimedRewards(address executor) external view returns (uint256 unclaimed);\n\n /// @notice Get the total execution fee for a transaction.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the execution fee for.\n function executionFee(uint256 dstChainId, bytes32 transactionId) external view returns (uint256 fee);\n\n /// @notice Get the address of the recorded executor for a transaction.\n /// @dev Will return address(0) if the executor is not recorded.\n /// @param dstChainId The chain id of the destination chain.\n /// @param transactionId The id of the transaction to get the recorded executor for.\n function recordedExecutor(uint256 dstChainId, bytes32 transactionId) external view returns (address executor);\n}\n\n// contracts/interfaces/IExecutionService.sol\n\ninterface IExecutionService {\n /// @notice Request the execution of an Interchain Transaction on a remote chain.\n /// Note: the off-chain actor needs to fetch the transaction payload from the InterchainClient\n /// event with the same transactionId, then execute the transaction on the remote chain:\n /// `dstInterchainClient.executeTransaction(transactionPayload)`\n /// Once the execution is confirmed on the source chain, the off-chain actor will be able\n /// to claim `executionFee` in the ExecutionFees contract.\n /// @dev Could only be called by `InterchainClient` contracts.\n /// Will revert if the execution fee is not big enough.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param transactionId The id of the transaction to execute.\n /// @param executionFee The fee paid for the execution.\n /// @param options The options to use for the execution.\n function requestExecution(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes32 transactionId,\n uint256 executionFee,\n bytes memory options\n )\n external;\n\n /// @notice Get the address of the EOA account that will be used to execute transactions on the\n /// remote chains.\n function executorEOA() external view returns (address);\n\n /// @notice Get the execution fee for executing an Interchain Transaction on a remote chain.\n /// @param dstChainId The chain id of the destination chain.\n /// @param txPayloadSize The size of the transaction payload to use for the execution.\n /// @param options The options to use for the execution.\n function getExecutionFee(\n uint256 dstChainId,\n uint256 txPayloadSize,\n bytes memory options\n )\n external\n view\n returns (uint256);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/InterchainBatch.sol\n\n/// @notice Struct representing a batch of entries in the Interchain DataBase.\n/// Batched entries are put together in a Merkle tree, which root is saved.\n/// Batch has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce\n/// - value: batchRoot\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch\n/// @param batchRoot The root of the Merkle tree containing the batched entries\nstruct InterchainBatch {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n bytes32 batchRoot;\n}\n\nlibrary InterchainBatchLib {\n /// @notice Constructs an InterchainBatch struct to be saved on the local chain.\n /// @param dbNonce The database nonce of the batch\n /// @param batchRoot The root of the Merkle tree containing the batched entries\n /// @return batch The constructed InterchainBatch struct\n function constructLocalBatch(\n uint256 dbNonce,\n bytes32 batchRoot\n )\n internal\n view\n returns (InterchainBatch memory batch)\n {\n return InterchainBatch({srcChainId: block.chainid, dbNonce: dbNonce, batchRoot: batchRoot});\n }\n\n /// @notice Returns the globally unique identifier of the batch\n function batchKey(InterchainBatch memory batch) internal pure returns (bytes32) {\n return keccak256(abi.encode(batch.srcChainId, batch.dbNonce));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/InterchainEntry.sol\n\n/// @notice Struct representing an entry in the Interchain DataBase.\n/// Entry has a globally unique identifier (key) and a value.\n/// - key: srcChainId + dbNonce + entryIndex\n/// - value: srcWriter + dataHash\n/// @param srcChainId The chain id of the source chain\n/// @param dbNonce The database nonce of the batch containing the entry\n/// @param entryIndex The index of the entry in the batch\n/// @param srcWriter The address of the writer on the source chain\n/// @param dataHash The hash of the data written on the source chain\nstruct InterchainEntry {\n // TODO: can we use uint64 for chain id?\n uint256 srcChainId;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes32 srcWriter;\n bytes32 dataHash;\n}\n\nusing InterchainEntryLib for InterchainEntry global;\n\nlibrary InterchainEntryLib {\n /// @notice Constructs an InterchainEntry struct to be written on the local chain\n /// @param dbNonce The database nonce of the entry on the source chain\n /// @param writer The address of the writer on the local chain\n /// @param dataHash The hash of the data written on the local chain\n /// @return entry The constructed InterchainEntry struct\n function constructLocalEntry(\n uint256 dbNonce,\n uint64 entryIndex,\n address writer,\n bytes32 dataHash\n )\n internal\n view\n returns (InterchainEntry memory entry)\n {\n return InterchainEntry({\n srcChainId: block.chainid,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n srcWriter: TypeCasts.addressToBytes32(writer),\n dataHash: dataHash\n });\n }\n\n /// @notice Returns the globally unique identifier of the entry\n function entryKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce, entry.entryIndex));\n }\n\n /// @notice Returns the value of the entry: writer + dataHash hashed together\n function entryValue(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcWriter, entry.dataHash));\n }\n\n /// @notice Returns the globally unique identifier of the batch containing the entry\n function batchKey(InterchainEntry memory entry) internal pure returns (bytes32) {\n return keccak256(abi.encode(entry.srcChainId, entry.dbNonce));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/Ownable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// contracts/interfaces/IInterchainDB.sol\n\ninterface IInterchainDB {\n /// @notice Struct representing a batch of entries from the remote Interchain DataBase,\n /// verified by the Interchain Module.\n /// @param verifiedAt The block timestamp at which the entry was verified by the module\n /// @param batchRoot The Merkle root of the batch\n struct RemoteBatch {\n uint256 verifiedAt;\n bytes32 batchRoot;\n }\n\n error InterchainDB__BatchDoesNotExist(uint256 dbNonce);\n error InterchainDB__BatchNotFinalized(uint256 dbNonce);\n error InterchainDB__ConflictingBatches(address module, bytes32 existingBatchRoot, InterchainBatch newBatch);\n error InterchainDB__EntryIndexOutOfRange(uint256 dbNonce, uint64 entryIndex, uint64 batchSize);\n error InterchainDB__IncorrectFeeAmount(uint256 actualFee, uint256 expectedFee);\n error InterchainDB__InvalidEntryRange(uint256 dbNonce, uint64 start, uint64 end);\n error InterchainDB__NoModulesSpecified();\n error InterchainDB__SameChainId(uint256 chainId);\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Note: there are no guarantees that this entry will be available for reading on any of the remote chains.\n /// Use `requestBatchVerification` to ensure that the entry is available for reading on the destination chain.\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntry(bytes32 dataHash) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Request the given Interchain Modules to verify an existing batch.\n /// If the batch is not finalized, the module will verify it after finalization.\n /// For the finalized batch the batch root is already available, and the module can verify it immediately.\n /// Note: every module has a separate fee paid in the native gas token of the source chain,\n /// and `msg.value` must be equal to the sum of all fees.\n /// Note: this method is permissionless, and anyone can request verification for any batch.\n /// @dev Will revert if the batch with the given nonce does not exist.\n /// @param dstChainId The chain id of the destination chain\n /// @param dbNonce The database nonce of the existing batch\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function requestBatchVerification(\n uint256 dstChainId,\n uint256 dbNonce,\n address[] memory srcModules\n )\n external\n payable;\n\n /// @notice Write data to the Interchain DataBase as a new entry in the current batch.\n /// Then request the Interchain Modules to verify the batch containing the written entry on the destination chain.\n /// See `writeEntry` and `requestBatchVerification` for more details.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param dataHash The hash of the data to be written to the Interchain DataBase as a new entry\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n /// @return dbNonce The database nonce of the batch containing the written entry\n /// @return entryIndex The index of the written entry within the batch\n function writeEntryWithVerification(\n uint256 dstChainId,\n bytes32 dataHash,\n address[] memory srcModules\n )\n external\n payable\n returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Allows the Interchain Module to verify the batch coming from the remote chain.\n /// @param batch The Interchain Batch to confirm\n function verifyRemoteBatch(InterchainBatch memory batch) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Get the fee for writing data to the Interchain DataBase, and verifying it on the destination chain\n /// using the provided Interchain Modules.\n /// @dev Will revert if the empty array of modules is provided.\n /// @param dstChainId The chain id of the destination chain\n /// @param srcModules The source chain addresses of the Interchain Modules to use for verification\n function getInterchainFee(uint256 dstChainId, address[] memory srcModules) external view returns (uint256);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce.\n /// Note: the leafs are ordered by the index of the written entry in the current batch,\n /// and the leafs value match the value of the written entry (srcWriter + dataHash hashed together).\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchLeafs(uint256 dbNonce) external view returns (bytes32[] memory);\n\n /// @notice Returns the list of leafs of the finalized batch with the given nonce,\n /// paginated by the given start and end indexes. The end index is exclusive.\n /// Note: this is useful when the batch contains a large number of leafs, and calling `getBatchLeafs`\n /// would result in a gas limit exceeded error.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the provided range is invalid.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param start The start index of the paginated leafs, inclusive\n /// @param end The end index of the paginated leafs, exclusive\n function getBatchLeafsPaginated(\n uint256 dbNonce,\n uint64 start,\n uint64 end\n )\n external\n view\n returns (bytes32[] memory);\n\n /// @notice Returns the size of the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatchSize(uint256 dbNonce) external view returns (uint64);\n\n /// @notice Get the finalized Interchain Batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// @param dbNonce The database nonce of the finalized batch\n function getBatch(uint256 dbNonce) external view returns (InterchainBatch memory);\n\n /// @notice Get the Interchain Entry's value written on the local chain with the given batch nonce and entry index.\n /// Entry value is calculated as the hash of the writer address and the written data hash.\n /// Note: the batch does not have to be finalized to fetch the entry value.\n /// @dev Will revert if the batch with the given nonce does not exist,\n /// or the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the existing batch\n /// @param entryIndex The index of the written entry within the batch\n function getEntryValue(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32);\n\n /// @notice Get the Merkle proof of inclusion for the entry with the given index\n /// in the finalized batch with the given nonce.\n /// @dev Will revert if the batch with the given nonce does not exist, or is not finalized.\n /// Will revert if the entry with the given index does not exist within the batch.\n /// @param dbNonce The database nonce of the finalized batch\n /// @param entryIndex The index of the written entry within the batch\n /// @return proof The Merkle proof of inclusion for the entry\n function getEntryProof(uint256 dbNonce, uint64 entryIndex) external view returns (bytes32[] memory proof);\n\n /// @notice Get the nonce of the database, which is incremented every time a new batch is finalized.\n /// This is the nonce of the current non-finalized batch.\n function getDBNonce() external view returns (uint256);\n\n /// @notice Get the index of the next entry to be written to the database.\n /// @return dbNonce The database nonce of the batch including the next entry\n /// @return entryIndex The index of the next entry within that batch\n function getNextEntryIndex() external view returns (uint256 dbNonce, uint64 entryIndex);\n\n /// @notice Read the data written on specific source chain by a specific writer,\n /// and verify it on the destination chain using the provided Interchain Module.\n /// Note: returned zero value indicates that the module has not verified the entry.\n /// @param entry The Interchain Entry to read\n /// @param dstModule The destination chain addresses of the Interchain Modules to use for verification\n /// @return moduleVerifiedAt The block timestamp at which the entry was verified by the module,\n /// or ZERO if the module has not verified the entry.\n function checkVerification(\n address dstModule,\n InterchainEntry memory entry,\n bytes32[] memory proof\n )\n external\n view\n returns (uint256 moduleVerifiedAt);\n}\n\n// contracts/InterchainClientV1.sol\n\n/**\n * @title InterchainClientV1\n * @dev Implements the operations of the Interchain Execution Layer.\n */\ncontract InterchainClientV1 is Ownable, InterchainClientV1Events, IInterchainClientV1 {\n using AppConfigLib for bytes;\n using OptionsLib for bytes;\n\n /// @notice Address of the InterchainDB contract, set at the time of deployment.\n address public immutable INTERCHAIN_DB;\n\n /// @notice Address of the contract that handles execution fees. Can be updated by the owner.\n address public executionFees;\n\n /// @dev Address of the InterchainClient contract on the remote chain\n mapping(uint256 chainId =\u003e bytes32 remoteClient) internal _linkedClient;\n /// @dev Executor address that completed the transaction. Address(0) if not executed yet.\n mapping(bytes32 transactionId =\u003e address executor) internal _txExecutor;\n\n constructor(address interchainDB, address owner_) Ownable(owner_) {\n INTERCHAIN_DB = interchainDB;\n }\n\n // @inheritdoc IInterchainClientV1\n function setExecutionFees(address executionFees_) external onlyOwner {\n executionFees = executionFees_;\n emit ExecutionFeesSet(executionFees_);\n }\n\n // @inheritdoc IInterchainClientV1\n function setLinkedClient(uint256 chainId, bytes32 client) external onlyOwner {\n _linkedClient[chainId] = client;\n emit LinkedClientSet(chainId, client);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n return _interchainSend(dstChainId, receiver, srcExecutionService, srcModules, options, message);\n }\n\n // @inheritdoc IInterchainClientV1\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc)\n {\n bytes32 receiverBytes32 = TypeCasts.addressToBytes32(receiver);\n return _interchainSend(dstChainId, receiverBytes32, srcExecutionService, srcModules, options, message);\n }\n\n // TODO: Handle the case where receiver does not implement the IInterchainApp interface (or does not exist at all)\n // @inheritdoc IInterchainClientV1\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable\n {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(transaction);\n bytes32 transactionId = _assertExecutable(icTx, proof);\n _txExecutor[transactionId] = msg.sender;\n\n OptionsV1 memory decodedOptions = icTx.options.decodeOptionsV1();\n if (msg.value != decodedOptions.gasAirdrop) {\n revert InterchainClientV1__IncorrectMsgValue(msg.value, decodedOptions.gasAirdrop);\n }\n // We should always use at least as much as the requested gas limit.\n // The executor can specify a higher gas limit if they wanted.\n if (decodedOptions.gasLimit \u003e gasLimit) gasLimit = decodedOptions.gasLimit;\n // Pass the full msg.value to the app: we have already checked that it matches the requested gas airdrop.\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).appReceive{gas: gasLimit, value: msg.value}({\n srcChainId: icTx.srcChainId,\n sender: icTx.srcSender,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n message: icTx.message\n });\n emit InterchainTransactionReceived(\n transactionId, icTx.dbNonce, icTx.entryIndex, icTx.srcChainId, icTx.srcSender, icTx.dstReceiver\n );\n }\n\n /// @inheritdoc IInterchainClientV1\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex) {\n address executor = _txExecutor[transactionId];\n if (executor == address(0)) {\n revert InterchainClientV1__TxNotExecuted(transactionId);\n }\n bytes memory proof = abi.encode(transactionId, executor);\n (dbNonce, entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntry(keccak256(proof));\n emit ExecutionProofWritten(transactionId, dbNonce, entryIndex, executor);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n // @inheritdoc IInterchainClientV1\n function isExecutable(bytes calldata encodedTx, bytes32[] calldata proof) external view returns (bool) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n // Check that options could be decoded\n icTx.options.decodeOptionsV1();\n _assertExecutable(icTx, proof);\n return true;\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutor(bytes calldata encodedTx) external view returns (address) {\n InterchainTransaction memory icTx = InterchainTransactionLib.decodeTransaction(encodedTx);\n return _txExecutor[icTx.transactionId()];\n }\n\n // @inheritdoc IInterchainClientV1\n function getExecutorById(bytes32 transactionId) external view returns (address) {\n return _txExecutor[transactionId];\n }\n\n // @inheritdoc IInterchainClientV1\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256 fee)\n {\n _assertLinkedClient(dstChainId);\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n // Verification fee from InterchainDB\n fee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n // Add execution fee, if ExecutionService is provided\n if (srcExecutionService != address(0)) {\n uint256 payloadSize = InterchainTransactionLib.payloadSize(options.length, messageLen);\n fee += IExecutionService(srcExecutionService).getExecutionFee(dstChainId, payloadSize, options);\n }\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClient(uint256 chainId) external view returns (bytes32) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n return _linkedClient[chainId];\n }\n\n /// @inheritdoc IInterchainClientV1\n function getLinkedClientEVM(uint256 chainId) external view returns (address linkedClientEVM) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n bytes32 linkedClient = _linkedClient[chainId];\n linkedClientEVM = TypeCasts.bytes32ToAddress(linkedClient);\n // Check that the linked client address fits into the EVM address space\n if (TypeCasts.addressToBytes32(linkedClientEVM) != linkedClient) {\n revert InterchainClientV1__NotEVMClient(linkedClient);\n }\n }\n\n /// @notice Decodes the encoded options data into a OptionsV1 struct.\n function decodeOptions(bytes memory encodedOptions) external view returns (OptionsV1 memory) {\n return encodedOptions.decodeOptionsV1();\n }\n\n /// @notice Encodes the transaction data into a bytes format.\n function encodeTransaction(InterchainTransaction memory icTx) external pure returns (bytes memory) {\n return icTx.encodeTransaction();\n }\n\n // ═════════════════════════════════════════════════ INTERNAL ══════════════════════════════════════════════════════\n\n /// @dev Internal logic for sending a message to another chain.\n function _interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n _assertLinkedClient(dstChainId);\n if (receiver == 0) revert InterchainClientV1__ZeroReceiver();\n // Check that options could be decoded on destination chain\n options.decodeOptionsV1();\n uint256 verificationFee = IInterchainDB(INTERCHAIN_DB).getInterchainFee(dstChainId, srcModules);\n if (msg.value \u003c verificationFee) {\n revert InterchainClientV1__FeeAmountTooLow(msg.value, verificationFee);\n }\n (desc.dbNonce, desc.entryIndex) = IInterchainDB(INTERCHAIN_DB).getNextEntryIndex();\n InterchainTransaction memory icTx = InterchainTransactionLib.constructLocalTransaction({\n srcSender: msg.sender,\n dstReceiver: receiver,\n dstChainId: dstChainId,\n dbNonce: desc.dbNonce,\n entryIndex: desc.entryIndex,\n options: options,\n message: message\n });\n desc.transactionId = icTx.transactionId();\n // Sanity check: nonce returned from DB should match the nonce used to construct the transaction\n {\n (uint256 dbNonce, uint64 entryIndex) = IInterchainDB(INTERCHAIN_DB).writeEntryWithVerification{\n value: verificationFee\n }(icTx.dstChainId, desc.transactionId, srcModules);\n assert(dbNonce == desc.dbNonce \u0026\u0026 entryIndex == desc.entryIndex);\n }\n uint256 executionFee;\n unchecked {\n executionFee = msg.value - verificationFee;\n }\n if (executionFee \u003e 0) {\n IExecutionFees(executionFees).addExecutionFee{value: executionFee}(icTx.dstChainId, desc.transactionId);\n }\n // TODO: consider disallowing the use of empty srcExecutionService\n if (srcExecutionService != address(0)) {\n IExecutionService(srcExecutionService).requestExecution({\n dstChainId: dstChainId,\n txPayloadSize: InterchainTransactionLib.payloadSize(options.length, message.length),\n transactionId: desc.transactionId,\n executionFee: executionFee,\n options: options\n });\n address srcExecutorEOA = IExecutionService(srcExecutionService).executorEOA();\n IExecutionFees(executionFees).recordExecutor(icTx.dstChainId, desc.transactionId, srcExecutorEOA);\n }\n emit InterchainTransactionSent(\n desc.transactionId,\n icTx.dbNonce,\n icTx.entryIndex,\n icTx.dstChainId,\n icTx.srcSender,\n icTx.dstReceiver,\n verificationFee,\n executionFee,\n icTx.options,\n icTx.message\n );\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Asserts that the transaction is executable. Returns the transactionId for chaining purposes.\n function _assertExecutable(\n InterchainTransaction memory icTx,\n bytes32[] calldata proof\n )\n internal\n view\n returns (bytes32 transactionId)\n {\n bytes32 linkedClient = _assertLinkedClient(icTx.srcChainId);\n if (icTx.dstChainId != block.chainid) {\n revert InterchainClientV1__IncorrectDstChainId(icTx.dstChainId);\n }\n transactionId = icTx.transactionId();\n if (_txExecutor[transactionId] != address(0)) {\n revert InterchainClientV1__TxAlreadyExecuted(transactionId);\n }\n // Construct expected entry based on icTransaction data\n InterchainEntry memory icEntry = InterchainEntry({\n srcChainId: icTx.srcChainId,\n dbNonce: icTx.dbNonce,\n entryIndex: icTx.entryIndex,\n srcWriter: linkedClient,\n dataHash: transactionId\n });\n (bytes memory encodedAppConfig, address[] memory approvedDstModules) =\n IInterchainApp(TypeCasts.bytes32ToAddress(icTx.dstReceiver)).getReceivingConfig();\n AppConfigV1 memory appConfig = encodedAppConfig.decodeAppConfigV1();\n if (appConfig.requiredResponses == 0) {\n revert InterchainClientV1__ZeroRequiredResponses();\n }\n uint256 responses = _getFinalizedResponsesCount(approvedDstModules, icEntry, proof, appConfig.optimisticPeriod);\n if (responses \u003c appConfig.requiredResponses) {\n revert InterchainClientV1__NotEnoughResponses(responses, appConfig.requiredResponses);\n }\n }\n\n /// @dev Asserts that the chain is linked and returns the linked client address.\n function _assertLinkedClient(uint256 chainId) internal view returns (bytes32 linkedClient) {\n if (chainId == block.chainid) {\n revert InterchainClientV1__NotRemoteChainId(chainId);\n }\n linkedClient = _linkedClient[chainId];\n if (linkedClient == 0) {\n revert InterchainClientV1__NoLinkedClient(chainId);\n }\n }\n\n /**\n * @dev Calculates the number of responses that are considered finalized within the optimistic time period.\n * @param approvedModules Approved modules that could have confirmed the entry.\n * @param icEntry The InterchainEntry to confirm.\n * @param optimisticPeriod The time period in seconds within which a response is considered valid.\n * @return finalizedResponses The count of responses that are finalized within the optimistic time period.\n */\n function _getFinalizedResponsesCount(\n address[] memory approvedModules,\n InterchainEntry memory icEntry,\n bytes32[] calldata proof,\n uint256 optimisticPeriod\n )\n internal\n view\n returns (uint256 finalizedResponses)\n {\n for (uint256 i = 0; i \u003c approvedModules.length; ++i) {\n uint256 confirmedAt = IInterchainDB(INTERCHAIN_DB).checkVerification(approvedModules[i], icEntry, proof);\n // checkVerification() returns 0 if entry hasn't been confirmed by the module, so we check for that as well\n if (confirmedAt != 0 \u0026\u0026 confirmedAt + optimisticPeriod \u003c block.timestamp) {\n ++finalizedResponses;\n }\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"10503:3757:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;10503:3757:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"10503:3757:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/InterchainClientV1.sol\":\"VersionedPayloadLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/InterchainClientV1.sol\":{\"keccak256\":\"0x27c3e6eb0296b547e24b7d891ddef2c4993575177e357427836b8cca27b47471\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://409528a61abfc8e30706ec007f30f7ebfd6c916f83ebdab19058228dd4ce9565\",\"dweb:/ipfs/QmRxU9iBG1DfW2wGsinyordwvoSbDM3HwUzxuJrPyouxoN\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file diff --git a/sin-executor/contracts/mocks/interchainapp/interchainapp.abigen.go b/sin-executor/contracts/mocks/interchainapp/interchainapp.abigen.go index 69cbcfc6d0..f17d048b7e 100644 --- a/sin-executor/contracts/mocks/interchainapp/interchainapp.abigen.go +++ b/sin-executor/contracts/mocks/interchainapp/interchainapp.abigen.go @@ -2963,7 +2963,7 @@ func (_AccessControlEnumerable *AccessControlEnumerableFilterer) ParseRoleRevoke // AddressMetaData contains all meta data concerning the Address contract. var AddressMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203230dd8f2d173eb68c4c2c7d92606537a9549e74f0da4d75e37324ee8e53b4e164736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207fab21237433ebd54f1a50678d230e2a4e3457ad1c0aa0fe910a126bb3726c9e64736f6c63430008140033", } // AddressABI is the input ABI used to generate the binding from. @@ -3135,8 +3135,8 @@ func (_Address *AddressTransactorRaw) Transact(opts *bind.TransactOpts, method s // AppConfigLibMetaData contains all meta data concerning the AppConfigLib contract. var AppConfigLibMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ffa6bd398bb72ccdb08137624bfae12d35bcf63bb30c4de992ea43620836634564736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b54fc094ca85e678bfd68635c4ef2fc11e9a229a43ece4f62eca9f4f9060a8f964736f6c63430008140033", } // AppConfigLibABI is the input ABI used to generate the binding from. @@ -3649,7 +3649,7 @@ func (_ERC165 *ERC165CallerSession) SupportsInterface(interfaceId [4]byte) (bool // EnumerableSetMetaData contains all meta data concerning the EnumerableSet contract. var EnumerableSetMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203406d8761bcaa90c37a9d2682076909c59beb37ec671e3eadde0424a900fb9a364736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201ae3b573fa1c4e3c2c3277a6cd4c5e4c56e00e88c23a03bb6859c810cd636ce664736f6c63430008140033", } // EnumerableSetABI is the input ABI used to generate the binding from. @@ -3855,7 +3855,7 @@ var ExampleAppV1MetaData = &bind.MetaData{ "01ffc9a7": "supportsInterface(bytes4)", "3ccfd60b": "withdraw()", }, - Bin: "0x60806040523480156200001157600080fd5b50604051620024bf380380620024bf8339810160408190526200003491620001be565b806200004260008262000079565b506200007190507f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c848262000079565b5050620001e9565b600080620000888484620000b6565b90508015620000ad576000848152600160205260409020620000ab908462000164565b505b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166200015b576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055620001123390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620000b0565b506000620000b0565b6000620000ad836001600160a01b03841660008181526001830160205260408120546200015b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000b0565b600060208284031215620001d157600080fd5b81516001600160a01b0381168114620000ad57600080fd5b6122c680620001f96000396000f3fe6080604052600436106101d85760003560e01c80639010d07c11610102578063b9b74b1811610095578063cb5038fb11610064578063cb5038fb146105b7578063d547741f146105d7578063eb53b44e146105f7578063f22ba23d1461061757600080fd5b8063b9b74b181461052e578063bc0d912c1461055b578063c313c80714610579578063ca15c8731461059757600080fd5b8063a9ac04b6116100d1578063a9ac04b6146104b9578063af8fcc8e146104d9578063b2494df3146104f9578063b70c40b31461050e57600080fd5b80639010d07c1461040657806391d148541461043e578063a1aa5d6814610482578063a217fddf146104a457600080fd5b80632f2ff15d1161017a57806351a308021161014957806351a308021461037157806368a6984714610391578063764ca1e8146103a45780637717a647146103c457600080fd5b80632f2ff15d146102fc57806336568abe1461031c5780633ccfd60b1461033c578063496774b11461035157600080fd5b80631c489e4f116101b65780631c489e4f14610254578063248a9ca314610296578063282be0e9146102c6578063287bc057146102d957600080fd5b806301ffc9a7146101dd5780630d32b505146102125780630fb5915614610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b55565b610637565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004611c15565b610693565b005b34801561024057600080fd5b5061023261024f366004611c80565b610766565b34801561026057600080fd5b506102887f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8481565b604051908152602001610209565b3480156102a257600080fd5b506102886102b1366004611c9b565b60009081526020819052604090206001015490565b6102326102d4366004611cfd565b61079d565b3480156102e557600080fd5b506102ee61085b565b604051610209929190611e06565b34801561030857600080fd5b50610232610317366004611e2b565b610876565b34801561032857600080fd5b50610232610337366004611e2b565b6108a1565b34801561034857600080fd5b506102326108f2565b34801561035d57600080fd5b5061023261036c366004611c80565b61090a565b34801561037d57600080fd5b5061023261038c366004611e57565b61099a565b61023261039f366004611e8f565b6109ce565b3480156103b057600080fd5b506102886103bf366004611f02565b610ab2565b3480156103d057600080fd5b50604080518082018252600080825260209182015281518083019092526003548252600454908201526040516102099190611fd2565b34801561041257600080fd5b50610426610421366004611e57565b610add565b6040516001600160a01b039091168152602001610209565b34801561044a57600080fd5b506101fd610459366004611e2b565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561048e57600080fd5b50610497610afc565b6040516102099190611fe9565b3480156104b057600080fd5b50610288600081565b3480156104c557600080fd5b506104266104d4366004611c9b565b610b0d565b3480156104e557600080fd5b506102326104f4366004611e2b565b610b68565b34801561050557600080fd5b50610497610ba5565b34801561051a57600080fd5b50610232610529366004611c80565b610bb1565b34801561053a57600080fd5b50610288610549366004611c9b565b60009081526005602052604090205490565b34801561056757600080fd5b506002546001600160a01b0316610426565b34801561058557600080fd5b50600a546001600160a01b0316610426565b3480156105a357600080fd5b506102886105b2366004611c9b565b610c6e565b3480156105c357600080fd5b506102326105d2366004611c80565b610c85565b3480156105e357600080fd5b506102326105f2366004611e2b565b610d79565b34801561060357600080fd5b50610232610612366004611c80565b610d9e565b34801561062357600080fd5b50610232610632366004611ffc565b610dd1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061068d575061068d82610e05565b92915050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846106bd81610e9c565b815115806106cd57506020820151155b1561071957815160208301516040517f8bdc31dd000000000000000000000000000000000000000000000000000000008152600481019290925260248201526044015b60405180910390fd5b81516003819055602080840151600481905560408051938452918301527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a15050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461079081610e9c565b61079982610ea6565b5050565b60006107f5863460405180604001604052808981526020018881525086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f6592505050565b602080820151604080840151845182518c81529485019390935267ffffffffffffffff169083015260608201529091507f2ef16db2691a32543ce5591798c4992f4cfbbcd446874f1437d99da53d600e7c906080015b60405180910390a1505050505050565b606080610866610fb5565b9150610870610ba5565b90509091565b60008281526020819052604090206001015461089181610e9c565b61089b8383610fd8565b50505050565b6001600160a01b03811633146108e3576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108ed828261100d565b505050565b60006108fd81610e9c565b610907334761103a565b50565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461093481610e9c565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e9060200161075a565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846109c481610e9c565b6108ed8383611103565b6109d7336111b9565b610a0f576040517f0578f695000000000000000000000000000000000000000000000000000000008152336004820152602401610710565b468603610a4b576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101879052602401610710565b6000868152600560205260409020548514610a9c576040517f327f41230000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604401610710565b610aaa8686868686866111c6565b505050505050565b6000610ad48560405180604001604052808781526020018681525084516111ff565b95945050505050565b6000828152600160205260408120610af59083611218565b9392505050565b6060610b086006611224565b905090565b600081815260056020526040902054806001600160a01b0381168114610b62576040517ff04c4a4500000000000000000000000000000000000000000000000000000000815260048101829052602401610710565b50919050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610b9281610e9c565b6108ed836001600160a01b038416611103565b6060610b086008611224565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610bdb81610e9c565b6000610be8600884611231565b905080610c2c576040517fb12a48e60000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a1505050565b600081815260016020526040812061068d90611246565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610caf81610e9c565b6001600160a01b038216610cef576040517fa8ce0c2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610cfc600884611250565b905080610d40576040517f856e38ac0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610c61565b600082815260208190526040902060010154610d9481610e9c565b61089b838361100d565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dc881610e9c565b61079982611265565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dfb81610e9c565b6108ed8383611398565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461068d565b6109078133611479565b610eaf816111b9565b610ef0576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b610efb8160006114e5565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b031603610907576109076000611265565b6040805160608101825260008082526020820181905291810182905290610f8b84611501565b600087815260056020526040902054909150610fab90879087848761152d565b9695505050505050565b6040805180820190915260035481526004546020820152606090610b0890611501565b600080610fe584846116fa565b90508015610af55760008481526001602052604090206110059084611250565b509392505050565b60008061101a84846117c2565b90508015610af55760008481526001602052604090206110059084611231565b80471015611076576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610710565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110c3576040519150601f19603f3d011682016040523d82523d6000602084013e6110c8565b606091505b50509050806108ed576040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46820361113f576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101839052602401610710565b600081900361117a576040517fe04fb69600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526005602052604080822083905551829184917f622d488f4fb24881af2fe5b552b249253a21e4a6fa77d12e69f61ee0fdfb9a319190a35050565b600061068d600683611863565b7fc5b07cf0d424748241636d3a67366b44ac88118c42bef024abcb7fd138df79a686868686868660405161084b96959493929190612038565b60008061120b84611501565b9050610ad4858285611885565b6000610af58383611969565b60606000610af583611993565b6000610af5836001600160a01b0384166119ef565b600061068d825490565b6000610af5836001600160a01b038416611ae2565b61126e816111b9565b15801561128357506001600160a01b03811615155b156112c5576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b6002546001600160a01b03166001600160a01b0316816001600160a01b031603611326576040517f56c309440000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c1699060200160405180910390a150565b6001600160a01b0382166113d8576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e1826111b9565b15611423576040517f4ea647680000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610710565b61142e8260016114e5565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156107995761079982611265565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610799576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610710565b80156114f6576108ed600683611250565b6108ed600683611231565b606061068d6001836040516020016115199190611fd2565b604051602081830303815290604052611b29565b6040805160608101825260008082526020820181905291810191909152600061155e6002546001600160a01b031690565b90506001600160a01b0381166115a0576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4687036115dc576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b600086900361161a576040517f9a3e6bd400000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b8447101561165d576040517f5b59cdf200000000000000000000000000000000000000000000000000000000815247600482015260248101869052604401610710565b806001600160a01b03166398939d28868989611681600a546001600160a01b031690565b611689610ba5565b8a8a6040518863ffffffff1660e01b81526004016116ac969594939291906120ab565b60606040518083038185885af11580156116ca573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116ef919061210c565b979650505050505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166117ba576000838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556117723390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161068d565b50600061068d565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16156117ba576000838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161068d565b6001600160a01b03811660009081526001830160205260408120541515610af5565b60008061189a6002546001600160a01b031690565b90506001600160a01b0381166118dc576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806001600160a01b0316637a1277db866118fe600a546001600160a01b031690565b611906610ba5565b88886040518663ffffffff1660e01b815260040161192895949392919061216e565b602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad491906121bb565b6000826000018281548110611980576119806121d4565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156119e357602002820191906000526020600020905b8154815260200190600101908083116119cf575b50505050509050919050565b60008181526001830160205260408120548015611ad8576000611a13600183612203565b8554909150600090611a2790600190612203565b9050808214611a8c576000866000018281548110611a4757611a476121d4565b9060005260206000200154905080876000018481548110611a6a57611a6a6121d4565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a9d57611a9d61223d565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061068d565b600091505061068d565b60008181526001830160205260408120546117ba5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561068d565b60608282604051602001611b3e92919061226c565b604051602081830303815290604052905092915050565b600060208284031215611b6757600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610af557600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c0d57611c0d611b97565b604052919050565b600060408284031215611c2757600080fd5b6040516040810181811067ffffffffffffffff82111715611c4a57611c4a611b97565b604052823581526020928301359281019290925250919050565b80356001600160a01b0381168114611c7b57600080fd5b919050565b600060208284031215611c9257600080fd5b610af582611c64565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b50813567ffffffffffffffff811115611cde57600080fd5b602083019150836020828501011115611cf657600080fd5b9250929050565b600080600080600060808688031215611d1557600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff811115611d4157600080fd5b611d4d88828901611cb4565b969995985093965092949392505050565b6000815180845260005b81811015611d8457602081850181015186830182015201611d68565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600081518084526020808501945080840160005b83811015611dfb5781516001600160a01b031687529582019590820190600101611dd6565b509495945050505050565b604081526000611e196040830185611d5e565b8281036020840152610ad48185611dc2565b60008060408385031215611e3e57600080fd5b82359150611e4e60208401611c64565b90509250929050565b60008060408385031215611e6a57600080fd5b50508035926020909101359150565b67ffffffffffffffff8116811461090757600080fd5b60008060008060008060a08789031215611ea857600080fd5b8635955060208701359450604087013593506060870135611ec881611e79565b9250608087013567ffffffffffffffff811115611ee457600080fd5b611ef089828a01611cb4565b979a9699509497509295939492505050565b60008060008060808587031215611f1857600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff80821115611f4657600080fd5b818801915088601f830112611f5a57600080fd5b813581811115611f6c57611f6c611b97565b611f9c847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611bc6565b91508082528984828501011115611fb257600080fd5b808484018584013760008482840101525080935050505092959194509250565b81518152602080830151908201526040810161068d565b602081526000610af56020830184611dc2565b6000806040838503121561200f57600080fd5b61201883611c64565b91506020830135801515811461202d57600080fd5b809150509250929050565b86815285602082015284604082015267ffffffffffffffff8416606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b8681528560208201526001600160a01b038516604082015260c0606082015260006120d960c0830186611dc2565b82810360808401526120eb8186611d5e565b905082810360a08401526120ff8185611d5e565b9998505050505050505050565b60006060828403121561211e57600080fd5b6040516060810181811067ffffffffffffffff8211171561214157612141611b97565b80604052508251815260208301516020820152604083015161216281611e79565b60408201529392505050565b8581526001600160a01b038516602082015260a06040820152600061219660a0830186611dc2565b82810360608401526121a88186611d5e565b9150508260808301529695505050505050565b6000602082840312156121cd57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8181038181111561068d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60ff831681526040602082015260006122886040830184611d5e565b94935050505056fea264697066735822122095dbed07b0f6460afc4214ae8929780044e0fae3559ba69bbf6c0f6e78d8c2e964736f6c63430008140033", + Bin: "0x60806040523480156200001157600080fd5b50604051620024f0380380620024f08339810160408190526200003491620001be565b806200004260008262000079565b506200007190507f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c848262000079565b5050620001e9565b600080620000888484620000b6565b90508015620000ad576000848152600160205260409020620000ab908462000164565b505b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166200015b576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055620001123390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620000b0565b506000620000b0565b6000620000ad836001600160a01b03841660008181526001830160205260408120546200015b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000b0565b600060208284031215620001d157600080fd5b81516001600160a01b0381168114620000ad57600080fd5b6122f780620001f96000396000f3fe6080604052600436106101d85760003560e01c80639010d07c11610102578063b9b74b1811610095578063cb5038fb11610064578063cb5038fb146105b7578063d547741f146105d7578063eb53b44e146105f7578063f22ba23d1461061757600080fd5b8063b9b74b181461052e578063bc0d912c1461055b578063c313c80714610579578063ca15c8731461059757600080fd5b8063a9ac04b6116100d1578063a9ac04b6146104b9578063af8fcc8e146104d9578063b2494df3146104f9578063b70c40b31461050e57600080fd5b80639010d07c1461040657806391d148541461043e578063a1aa5d6814610482578063a217fddf146104a457600080fd5b80632f2ff15d1161017a57806351a308021161014957806351a308021461037157806368a6984714610391578063764ca1e8146103a45780637717a647146103c457600080fd5b80632f2ff15d146102fc57806336568abe1461031c5780633ccfd60b1461033c578063496774b11461035157600080fd5b80631c489e4f116101b65780631c489e4f14610254578063248a9ca314610296578063282be0e9146102c6578063287bc057146102d957600080fd5b806301ffc9a7146101dd5780630d32b505146102125780630fb5915614610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b55565b610637565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004611c15565b610693565b005b34801561024057600080fd5b5061023261024f366004611c80565b610766565b34801561026057600080fd5b506102887f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8481565b604051908152602001610209565b3480156102a257600080fd5b506102886102b1366004611c9b565b60009081526020819052604090206001015490565b6102326102d4366004611cfd565b61079d565b3480156102e557600080fd5b506102ee61085b565b604051610209929190611e10565b34801561030857600080fd5b50610232610317366004611e35565b610876565b34801561032857600080fd5b50610232610337366004611e35565b6108a1565b34801561034857600080fd5b506102326108f2565b34801561035d57600080fd5b5061023261036c366004611c80565b61090a565b34801561037d57600080fd5b5061023261038c366004611e61565b61099a565b61023261039f366004611e99565b6109ce565b3480156103b057600080fd5b506102886103bf366004611f0c565b610ab2565b3480156103d057600080fd5b50604080518082018252600080825260209182015281518083019092526003548252600454908201526040516102099190611fdc565b34801561041257600080fd5b50610426610421366004611e61565b610add565b6040516001600160a01b039091168152602001610209565b34801561044a57600080fd5b506101fd610459366004611e35565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561048e57600080fd5b50610497610afc565b6040516102099190611ff3565b3480156104b057600080fd5b50610288600081565b3480156104c557600080fd5b506104266104d4366004611c9b565b610b0d565b3480156104e557600080fd5b506102326104f4366004611e35565b610b68565b34801561050557600080fd5b50610497610ba5565b34801561051a57600080fd5b50610232610529366004611c80565b610bb1565b34801561053a57600080fd5b50610288610549366004611c9b565b60009081526005602052604090205490565b34801561056757600080fd5b506002546001600160a01b0316610426565b34801561058557600080fd5b50600a546001600160a01b0316610426565b3480156105a357600080fd5b506102886105b2366004611c9b565b610c6e565b3480156105c357600080fd5b506102326105d2366004611c80565b610c85565b3480156105e357600080fd5b506102326105f2366004611e35565b610d79565b34801561060357600080fd5b50610232610612366004611c80565b610d9e565b34801561062357600080fd5b50610232610632366004612006565b610dd1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061068d575061068d82610e05565b92915050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846106bd81610e9c565b815115806106cd57506020820151155b1561071957815160208301516040517f8bdc31dd000000000000000000000000000000000000000000000000000000008152600481019290925260248201526044015b60405180910390fd5b81516003819055602080840151600481905560408051938452918301527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a15050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461079081610e9c565b61079982610ea6565b5050565b60006107f5863460405180604001604052808981526020018881525086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f6592505050565b602080820151604080840151845182518c81529485019390935267ffffffffffffffff169083015260608201529091507f2ef16db2691a32543ce5591798c4992f4cfbbcd446874f1437d99da53d600e7c906080015b60405180910390a1505050505050565b606080610866610fb5565b9150610870610ba5565b90509091565b60008281526020819052604090206001015461089181610e9c565b61089b8383610fd8565b50505050565b6001600160a01b03811633146108e3576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108ed828261100d565b505050565b60006108fd81610e9c565b610907334761103a565b50565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461093481610e9c565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e9060200161075a565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846109c481610e9c565b6108ed8383611103565b6109d7336111b9565b610a0f576040517f0578f695000000000000000000000000000000000000000000000000000000008152336004820152602401610710565b468603610a4b576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101879052602401610710565b6000868152600560205260409020548514610a9c576040517f327f41230000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604401610710565b610aaa8686868686866111c6565b505050505050565b6000610ad48560405180604001604052808781526020018681525084516111ff565b95945050505050565b6000828152600160205260408120610af59083611218565b9392505050565b6060610b086006611224565b905090565b600081815260056020526040902054806001600160a01b0381168114610b62576040517ff04c4a4500000000000000000000000000000000000000000000000000000000815260048101829052602401610710565b50919050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610b9281610e9c565b6108ed836001600160a01b038416611103565b6060610b086008611224565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610bdb81610e9c565b6000610be8600884611231565b905080610c2c576040517fb12a48e60000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a1505050565b600081815260016020526040812061068d90611246565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610caf81610e9c565b6001600160a01b038216610cef576040517fa8ce0c2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610cfc600884611250565b905080610d40576040517f856e38ac0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610c61565b600082815260208190526040902060010154610d9481610e9c565b61089b838361100d565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dc881610e9c565b61079982611265565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dfb81610e9c565b6108ed8383611398565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461068d565b6109078133611479565b610eaf816111b9565b610ef0576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b610efb8160006114e5565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b031603610907576109076000611265565b6040805160608101825260008082526020820181905291810182905290610f8b84611501565b600087815260056020526040902054909150610fab90879087848761152d565b9695505050505050565b6040805180820190915260035481526004546020820152606090610b0890611501565b600080610fe584846116fa565b90508015610af55760008481526001602052604090206110059084611250565b509392505050565b60008061101a84846117c2565b90508015610af55760008481526001602052604090206110059084611231565b80471015611076576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610710565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110c3576040519150601f19603f3d011682016040523d82523d6000602084013e6110c8565b606091505b50509050806108ed576040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46820361113f576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101839052602401610710565b600081900361117a576040517fe04fb69600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526005602052604080822083905551829184917f622d488f4fb24881af2fe5b552b249253a21e4a6fa77d12e69f61ee0fdfb9a319190a35050565b600061068d600683611863565b7fc5b07cf0d424748241636d3a67366b44ac88118c42bef024abcb7fd138df79a686868686868660405161084b96959493929190612042565b60008061120b84611501565b9050610ad4858285611885565b6000610af58383611969565b60606000610af583611993565b6000610af5836001600160a01b0384166119ef565b600061068d825490565b6000610af5836001600160a01b038416611ae2565b61126e816111b9565b15801561128357506001600160a01b03811615155b156112c5576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b6002546001600160a01b03166001600160a01b0316816001600160a01b031603611326576040517f56c309440000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c1699060200160405180910390a150565b6001600160a01b0382166113d8576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e1826111b9565b15611423576040517f4ea647680000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610710565b61142e8260016114e5565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156107995761079982611265565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610799576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610710565b80156114f6576108ed600683611250565b6108ed600683611231565b606061068d6001836040516020016115199190611fdc565b604051602081830303815290604052611b29565b6040805160608101825260008082526020820181905291810191909152600061155e6002546001600160a01b031690565b90506001600160a01b0381166115a0576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4687036115dc576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b600086900361161a576040517f9a3e6bd400000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b8447101561165d576040517f5b59cdf200000000000000000000000000000000000000000000000000000000815247600482015260248101869052604401610710565b806001600160a01b03166398939d28868989611681600a546001600160a01b031690565b611689610ba5565b8a8a6040518863ffffffff1660e01b81526004016116ac969594939291906120b5565b60606040518083038185885af11580156116ca573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116ef9190612116565b979650505050505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166117ba576000838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556117723390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161068d565b50600061068d565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16156117ba576000838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161068d565b6001600160a01b03811660009081526001830160205260408120541515610af5565b60008061189a6002546001600160a01b031690565b90506001600160a01b0381166118dc576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806001600160a01b0316637a1277db866118fe600a546001600160a01b031690565b611906610ba5565b88886040518663ffffffff1660e01b8152600401611928959493929190612178565b602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad491906121c5565b6000826000018281548110611980576119806121de565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156119e357602002820191906000526020600020905b8154815260200190600101908083116119cf575b50505050509050919050565b60008181526001830160205260408120548015611ad8576000611a1360018361220d565b8554909150600090611a279060019061220d565b9050808214611a8c576000866000018281548110611a4757611a476121de565b9060005260206000200154905080876000018481548110611a6a57611a6a6121de565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a9d57611a9d612247565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061068d565b600091505061068d565b60008181526001830160205260408120546117ba5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561068d565b60608282604051602001611b3e929190612276565b604051602081830303815290604052905092915050565b600060208284031215611b6757600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610af557600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c0d57611c0d611b97565b604052919050565b600060408284031215611c2757600080fd5b6040516040810181811067ffffffffffffffff82111715611c4a57611c4a611b97565b604052823581526020928301359281019290925250919050565b80356001600160a01b0381168114611c7b57600080fd5b919050565b600060208284031215611c9257600080fd5b610af582611c64565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b50813567ffffffffffffffff811115611cde57600080fd5b602083019150836020828501011115611cf657600080fd5b9250929050565b600080600080600060808688031215611d1557600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff811115611d4157600080fd5b611d4d88828901611cb4565b969995985093965092949392505050565b60005b83811015611d79578181015183820152602001611d61565b50506000910152565b60008151808452611d9a816020860160208601611d5e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600081518084526020808501945080840160005b83811015611e055781516001600160a01b031687529582019590820190600101611de0565b509495945050505050565b604081526000611e236040830185611d82565b8281036020840152610ad48185611dcc565b60008060408385031215611e4857600080fd5b82359150611e5860208401611c64565b90509250929050565b60008060408385031215611e7457600080fd5b50508035926020909101359150565b67ffffffffffffffff8116811461090757600080fd5b60008060008060008060a08789031215611eb257600080fd5b8635955060208701359450604087013593506060870135611ed281611e83565b9250608087013567ffffffffffffffff811115611eee57600080fd5b611efa89828a01611cb4565b979a9699509497509295939492505050565b60008060008060808587031215611f2257600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff80821115611f5057600080fd5b818801915088601f830112611f6457600080fd5b813581811115611f7657611f76611b97565b611fa6847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611bc6565b91508082528984828501011115611fbc57600080fd5b808484018584013760008482840101525080935050505092959194509250565b81518152602080830151908201526040810161068d565b602081526000610af56020830184611dcc565b6000806040838503121561201957600080fd5b61202283611c64565b91506020830135801515811461203757600080fd5b809150509250929050565b86815285602082015284604082015267ffffffffffffffff8416606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b8681528560208201526001600160a01b038516604082015260c0606082015260006120e360c0830186611dcc565b82810360808401526120f58186611d82565b905082810360a08401526121098185611d82565b9998505050505050505050565b60006060828403121561212857600080fd5b6040516060810181811067ffffffffffffffff8211171561214b5761214b611b97565b80604052508251815260208301516020820152604083015161216c81611e83565b60408201529392505050565b8581526001600160a01b038516602082015260a0604082015260006121a060a0830186611dcc565b82810360608401526121b28186611d82565b9150508260808301529695505050505050565b6000602082840312156121d757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8181038181111561068d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b168152600082516122b3816002850160208701611d5e565b91909101600201939250505056fea2646970667358221220d14e9c75b1404f40a6358d9573f563fb2dee2ed56dc07a00419c29e57cef150b64736f6c63430008140033", } // ExampleAppV1ABI is the input ABI used to generate the binding from. @@ -13218,7 +13218,7 @@ func (_InterchainAppV1Events *InterchainAppV1EventsFilterer) ParseTrustedModuleR // InterchainTransactionLibMetaData contains all meta data concerning the InterchainTransactionLib contract. var InterchainTransactionLibMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203b59d7a47fc00d5e1c1ab9bd21c738f0c2793102645062a014bae88c82b5faab64736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220accceebe9679b3ac91ab2de0807ed97aa77b6c6556c8e5b5929ea06f1c37c75a64736f6c63430008140033", } // InterchainTransactionLibABI is the input ABI used to generate the binding from. @@ -13391,7 +13391,7 @@ func (_InterchainTransactionLib *InterchainTransactionLibTransactorRaw) Transact // MathLibMetaData contains all meta data concerning the MathLib contract. var MathLibMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b80747f8b8557b57a660253e634169764fff20fd7ee781fdc40e26936688207964736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f957455d0e937771907f72d1079f7de532fee96656aff32d2c15ec9aa8c996a964736f6c63430008140033", } // MathLibABI is the input ABI used to generate the binding from. @@ -13563,8 +13563,8 @@ func (_MathLib *MathLibTransactorRaw) Transact(opts *bind.TransactOpts, method s // OptionsLibMetaData contains all meta data concerning the OptionsLib contract. var OptionsLibMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212205820c4692021c760667fde1e3a50aa3286939777631d2b04cd8c72dc5105879664736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207d869ce787cbbb5212c74841e7164c6ad54b17e4cec09637745dd8901a6d279964736f6c63430008140033", } // OptionsLibABI is the input ABI used to generate the binding from. @@ -13737,7 +13737,7 @@ func (_OptionsLib *OptionsLibTransactorRaw) Transact(opts *bind.TransactOpts, me // TypeCastsMetaData contains all meta data concerning the TypeCasts contract. var TypeCastsMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204d640c45c6f44a8c6c3918b01efb07db9ef2045645900d94931f2cb81901643664736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f979f496a09f113b5f662c0f5c4d4aff1d533844c8e5cabf35cbd41980c56db264736f6c63430008140033", } // TypeCastsABI is the input ABI used to generate the binding from. @@ -13906,3 +13906,176 @@ func (_TypeCasts *TypeCastsTransactorRaw) Transfer(opts *bind.TransactOpts) (*ty func (_TypeCasts *TypeCastsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { return _TypeCasts.Contract.contract.Transact(opts, method, params...) } + +// VersionedPayloadLibMetaData contains all meta data concerning the VersionedPayloadLib contract. +var VersionedPayloadLibMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122000d9abcc4f15b9b07c85217b76ddf623350b0b562e782f8870d2001634c9838f64736f6c63430008140033", +} + +// VersionedPayloadLibABI is the input ABI used to generate the binding from. +// Deprecated: Use VersionedPayloadLibMetaData.ABI instead. +var VersionedPayloadLibABI = VersionedPayloadLibMetaData.ABI + +// VersionedPayloadLibBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use VersionedPayloadLibMetaData.Bin instead. +var VersionedPayloadLibBin = VersionedPayloadLibMetaData.Bin + +// DeployVersionedPayloadLib deploys a new Ethereum contract, binding an instance of VersionedPayloadLib to it. +func DeployVersionedPayloadLib(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *VersionedPayloadLib, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(VersionedPayloadLibBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// VersionedPayloadLib is an auto generated Go binding around an Ethereum contract. +type VersionedPayloadLib struct { + VersionedPayloadLibCaller // Read-only binding to the contract + VersionedPayloadLibTransactor // Write-only binding to the contract + VersionedPayloadLibFilterer // Log filterer for contract events +} + +// VersionedPayloadLibCaller is an auto generated read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibTransactor is an auto generated write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type VersionedPayloadLibFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type VersionedPayloadLibSession struct { + Contract *VersionedPayloadLib // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type VersionedPayloadLibCallerSession struct { + Contract *VersionedPayloadLibCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// VersionedPayloadLibTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type VersionedPayloadLibTransactorSession struct { + Contract *VersionedPayloadLibTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibRaw is an auto generated low-level Go binding around an Ethereum contract. +type VersionedPayloadLibRaw struct { + Contract *VersionedPayloadLib // Generic contract binding to access the raw methods on +} + +// VersionedPayloadLibCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCallerRaw struct { + Contract *VersionedPayloadLibCaller // Generic read-only contract binding to access the raw methods on +} + +// VersionedPayloadLibTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactorRaw struct { + Contract *VersionedPayloadLibTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewVersionedPayloadLib creates a new instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLib(address common.Address, backend bind.ContractBackend) (*VersionedPayloadLib, error) { + contract, err := bindVersionedPayloadLib(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// NewVersionedPayloadLibCaller creates a new read-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibCaller(address common.Address, caller bind.ContractCaller) (*VersionedPayloadLibCaller, error) { + contract, err := bindVersionedPayloadLib(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibCaller{contract: contract}, nil +} + +// NewVersionedPayloadLibTransactor creates a new write-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibTransactor(address common.Address, transactor bind.ContractTransactor) (*VersionedPayloadLibTransactor, error) { + contract, err := bindVersionedPayloadLib(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibTransactor{contract: contract}, nil +} + +// NewVersionedPayloadLibFilterer creates a new log filterer instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibFilterer(address common.Address, filterer bind.ContractFilterer) (*VersionedPayloadLibFilterer, error) { + contract, err := bindVersionedPayloadLib(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &VersionedPayloadLibFilterer{contract: contract}, nil +} + +// bindVersionedPayloadLib binds a generic wrapper to an already deployed contract. +func bindVersionedPayloadLib(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.VersionedPayloadLibCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transact(opts, method, params...) +} diff --git a/sin-executor/contracts/mocks/interchainapp/interchainapp.contractinfo.json b/sin-executor/contracts/mocks/interchainapp/interchainapp.contractinfo.json index 2e0f8e9945..9f09a3a112 100644 --- a/sin-executor/contracts/mocks/interchainapp/interchainapp.contractinfo.json +++ b/sin-executor/contracts/mocks/interchainapp/interchainapp.contractinfo.json @@ -1 +1 @@ -{"solidity/ExampleAppV1.sol:AbstractICApp":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__AlreadyLatestClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainApp__BalanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__ClientAlreadyAdded","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__ReceiverNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__SameChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."}},"version":1},"developerDoc":{"kind":"dev","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__AlreadyLatestClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__BalanceTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__ClientAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__InterchainClientZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"InterchainApp__NotInterchainClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__ReceiverNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__SenderNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AbstractICApp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getReceivingConfig()":"287bc057"}},"solidity/ExampleAppV1.sol:AbstractICAppEvents":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AbstractICAppEvents\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:AccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:AccessControlEnumerable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Extension of {AccessControl} that allows enumerating the members of each role.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Extension of {AccessControl} that allows enumerating the members of each role.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AccessControlEnumerable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:Address":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203230dd8f2d173eb68c4c2c7d92606537a9549e74f0da4d75e37324ee8e53b4e164736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203230dd8f2d173eb68c4c2c7d92606537a9549e74f0da4d75e37324ee8e53b4e164736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"11370:6066:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;11370:6066:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"11370:6066:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Collection of functions related to the address type","errors":{"AddressEmptyCode(address)":[{"details":"There's no code at `target` (it is not a contract)."}],"AddressInsufficientBalance(address)":[{"details":"The ETH balance of the account is not enough to perform the operation."}],"FailedInnerCall()":[{"details":"A call to an address target failed. The target may have reverted."}]},"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"}],\"devdoc\":{\"details\":\"Collection of functions related to the address type\",\"errors\":{\"AddressEmptyCode(address)\":[{\"details\":\"There's no code at `target` (it is not a contract).\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}]},\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"Address\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:AppConfigLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ffa6bd398bb72ccdb08137624bfae12d35bcf63bb30c4de992ea43620836634564736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ffa6bd398bb72ccdb08137624bfae12d35bcf63bb30c4de992ea43620836634564736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"2606:2072:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;2606:2072:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"2606:2072:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"AppConfigLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AppConfigLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:Context":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"Context\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:ERC165":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```","kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```\",\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"ERC165\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:EnumerableSet":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203406d8761bcaa90c37a9d2682076909c59beb37ec671e3eadde0424a900fb9a364736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203406d8761bcaa90c37a9d2682076909c59beb37ec671e3eadde0424a900fb9a364736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"20633:11640:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;20633:11640:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"20633:11640:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time (O(1)). - Elements are enumerated in O(n). No guarantees are made on the ordering. ```solidity contract Example { // Add the library methods using EnumerableSet for EnumerableSet.AddressSet; // Declare a set state variable EnumerableSet.AddressSet private mySet; } ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) and `uint256` (`UintSet`) are supported. [WARNING] ==== Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. ====","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time (O(1)). - Elements are enumerated in O(n). No guarantees are made on the ordering. ```solidity contract Example { // Add the library methods using EnumerableSet for EnumerableSet.AddressSet; // Declare a set state variable EnumerableSet.AddressSet private mySet; } ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) and `uint256` (`UintSet`) are supported. [WARNING] ==== Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. ====\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"EnumerableSet\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:ExampleAppV1":{"code":"0x60806040523480156200001157600080fd5b50604051620024bf380380620024bf8339810160408190526200003491620001be565b806200004260008262000079565b506200007190507f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c848262000079565b5050620001e9565b600080620000888484620000b6565b90508015620000ad576000848152600160205260409020620000ab908462000164565b505b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166200015b576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055620001123390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620000b0565b506000620000b0565b6000620000ad836001600160a01b03841660008181526001830160205260408120546200015b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000b0565b600060208284031215620001d157600080fd5b81516001600160a01b0381168114620000ad57600080fd5b6122c680620001f96000396000f3fe6080604052600436106101d85760003560e01c80639010d07c11610102578063b9b74b1811610095578063cb5038fb11610064578063cb5038fb146105b7578063d547741f146105d7578063eb53b44e146105f7578063f22ba23d1461061757600080fd5b8063b9b74b181461052e578063bc0d912c1461055b578063c313c80714610579578063ca15c8731461059757600080fd5b8063a9ac04b6116100d1578063a9ac04b6146104b9578063af8fcc8e146104d9578063b2494df3146104f9578063b70c40b31461050e57600080fd5b80639010d07c1461040657806391d148541461043e578063a1aa5d6814610482578063a217fddf146104a457600080fd5b80632f2ff15d1161017a57806351a308021161014957806351a308021461037157806368a6984714610391578063764ca1e8146103a45780637717a647146103c457600080fd5b80632f2ff15d146102fc57806336568abe1461031c5780633ccfd60b1461033c578063496774b11461035157600080fd5b80631c489e4f116101b65780631c489e4f14610254578063248a9ca314610296578063282be0e9146102c6578063287bc057146102d957600080fd5b806301ffc9a7146101dd5780630d32b505146102125780630fb5915614610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b55565b610637565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004611c15565b610693565b005b34801561024057600080fd5b5061023261024f366004611c80565b610766565b34801561026057600080fd5b506102887f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8481565b604051908152602001610209565b3480156102a257600080fd5b506102886102b1366004611c9b565b60009081526020819052604090206001015490565b6102326102d4366004611cfd565b61079d565b3480156102e557600080fd5b506102ee61085b565b604051610209929190611e06565b34801561030857600080fd5b50610232610317366004611e2b565b610876565b34801561032857600080fd5b50610232610337366004611e2b565b6108a1565b34801561034857600080fd5b506102326108f2565b34801561035d57600080fd5b5061023261036c366004611c80565b61090a565b34801561037d57600080fd5b5061023261038c366004611e57565b61099a565b61023261039f366004611e8f565b6109ce565b3480156103b057600080fd5b506102886103bf366004611f02565b610ab2565b3480156103d057600080fd5b50604080518082018252600080825260209182015281518083019092526003548252600454908201526040516102099190611fd2565b34801561041257600080fd5b50610426610421366004611e57565b610add565b6040516001600160a01b039091168152602001610209565b34801561044a57600080fd5b506101fd610459366004611e2b565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561048e57600080fd5b50610497610afc565b6040516102099190611fe9565b3480156104b057600080fd5b50610288600081565b3480156104c557600080fd5b506104266104d4366004611c9b565b610b0d565b3480156104e557600080fd5b506102326104f4366004611e2b565b610b68565b34801561050557600080fd5b50610497610ba5565b34801561051a57600080fd5b50610232610529366004611c80565b610bb1565b34801561053a57600080fd5b50610288610549366004611c9b565b60009081526005602052604090205490565b34801561056757600080fd5b506002546001600160a01b0316610426565b34801561058557600080fd5b50600a546001600160a01b0316610426565b3480156105a357600080fd5b506102886105b2366004611c9b565b610c6e565b3480156105c357600080fd5b506102326105d2366004611c80565b610c85565b3480156105e357600080fd5b506102326105f2366004611e2b565b610d79565b34801561060357600080fd5b50610232610612366004611c80565b610d9e565b34801561062357600080fd5b50610232610632366004611ffc565b610dd1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061068d575061068d82610e05565b92915050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846106bd81610e9c565b815115806106cd57506020820151155b1561071957815160208301516040517f8bdc31dd000000000000000000000000000000000000000000000000000000008152600481019290925260248201526044015b60405180910390fd5b81516003819055602080840151600481905560408051938452918301527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a15050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461079081610e9c565b61079982610ea6565b5050565b60006107f5863460405180604001604052808981526020018881525086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f6592505050565b602080820151604080840151845182518c81529485019390935267ffffffffffffffff169083015260608201529091507f2ef16db2691a32543ce5591798c4992f4cfbbcd446874f1437d99da53d600e7c906080015b60405180910390a1505050505050565b606080610866610fb5565b9150610870610ba5565b90509091565b60008281526020819052604090206001015461089181610e9c565b61089b8383610fd8565b50505050565b6001600160a01b03811633146108e3576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108ed828261100d565b505050565b60006108fd81610e9c565b610907334761103a565b50565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461093481610e9c565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e9060200161075a565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846109c481610e9c565b6108ed8383611103565b6109d7336111b9565b610a0f576040517f0578f695000000000000000000000000000000000000000000000000000000008152336004820152602401610710565b468603610a4b576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101879052602401610710565b6000868152600560205260409020548514610a9c576040517f327f41230000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604401610710565b610aaa8686868686866111c6565b505050505050565b6000610ad48560405180604001604052808781526020018681525084516111ff565b95945050505050565b6000828152600160205260408120610af59083611218565b9392505050565b6060610b086006611224565b905090565b600081815260056020526040902054806001600160a01b0381168114610b62576040517ff04c4a4500000000000000000000000000000000000000000000000000000000815260048101829052602401610710565b50919050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610b9281610e9c565b6108ed836001600160a01b038416611103565b6060610b086008611224565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610bdb81610e9c565b6000610be8600884611231565b905080610c2c576040517fb12a48e60000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a1505050565b600081815260016020526040812061068d90611246565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610caf81610e9c565b6001600160a01b038216610cef576040517fa8ce0c2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610cfc600884611250565b905080610d40576040517f856e38ac0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610c61565b600082815260208190526040902060010154610d9481610e9c565b61089b838361100d565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dc881610e9c565b61079982611265565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dfb81610e9c565b6108ed8383611398565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461068d565b6109078133611479565b610eaf816111b9565b610ef0576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b610efb8160006114e5565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b031603610907576109076000611265565b6040805160608101825260008082526020820181905291810182905290610f8b84611501565b600087815260056020526040902054909150610fab90879087848761152d565b9695505050505050565b6040805180820190915260035481526004546020820152606090610b0890611501565b600080610fe584846116fa565b90508015610af55760008481526001602052604090206110059084611250565b509392505050565b60008061101a84846117c2565b90508015610af55760008481526001602052604090206110059084611231565b80471015611076576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610710565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110c3576040519150601f19603f3d011682016040523d82523d6000602084013e6110c8565b606091505b50509050806108ed576040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46820361113f576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101839052602401610710565b600081900361117a576040517fe04fb69600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526005602052604080822083905551829184917f622d488f4fb24881af2fe5b552b249253a21e4a6fa77d12e69f61ee0fdfb9a319190a35050565b600061068d600683611863565b7fc5b07cf0d424748241636d3a67366b44ac88118c42bef024abcb7fd138df79a686868686868660405161084b96959493929190612038565b60008061120b84611501565b9050610ad4858285611885565b6000610af58383611969565b60606000610af583611993565b6000610af5836001600160a01b0384166119ef565b600061068d825490565b6000610af5836001600160a01b038416611ae2565b61126e816111b9565b15801561128357506001600160a01b03811615155b156112c5576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b6002546001600160a01b03166001600160a01b0316816001600160a01b031603611326576040517f56c309440000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c1699060200160405180910390a150565b6001600160a01b0382166113d8576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e1826111b9565b15611423576040517f4ea647680000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610710565b61142e8260016114e5565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156107995761079982611265565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610799576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610710565b80156114f6576108ed600683611250565b6108ed600683611231565b606061068d6001836040516020016115199190611fd2565b604051602081830303815290604052611b29565b6040805160608101825260008082526020820181905291810191909152600061155e6002546001600160a01b031690565b90506001600160a01b0381166115a0576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4687036115dc576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b600086900361161a576040517f9a3e6bd400000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b8447101561165d576040517f5b59cdf200000000000000000000000000000000000000000000000000000000815247600482015260248101869052604401610710565b806001600160a01b03166398939d28868989611681600a546001600160a01b031690565b611689610ba5565b8a8a6040518863ffffffff1660e01b81526004016116ac969594939291906120ab565b60606040518083038185885af11580156116ca573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116ef919061210c565b979650505050505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166117ba576000838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556117723390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161068d565b50600061068d565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16156117ba576000838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161068d565b6001600160a01b03811660009081526001830160205260408120541515610af5565b60008061189a6002546001600160a01b031690565b90506001600160a01b0381166118dc576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806001600160a01b0316637a1277db866118fe600a546001600160a01b031690565b611906610ba5565b88886040518663ffffffff1660e01b815260040161192895949392919061216e565b602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad491906121bb565b6000826000018281548110611980576119806121d4565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156119e357602002820191906000526020600020905b8154815260200190600101908083116119cf575b50505050509050919050565b60008181526001830160205260408120548015611ad8576000611a13600183612203565b8554909150600090611a2790600190612203565b9050808214611a8c576000866000018281548110611a4757611a476121d4565b9060005260206000200154905080876000018481548110611a6a57611a6a6121d4565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a9d57611a9d61223d565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061068d565b600091505061068d565b60008181526001830160205260408120546117ba5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561068d565b60608282604051602001611b3e92919061226c565b604051602081830303815290604052905092915050565b600060208284031215611b6757600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610af557600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c0d57611c0d611b97565b604052919050565b600060408284031215611c2757600080fd5b6040516040810181811067ffffffffffffffff82111715611c4a57611c4a611b97565b604052823581526020928301359281019290925250919050565b80356001600160a01b0381168114611c7b57600080fd5b919050565b600060208284031215611c9257600080fd5b610af582611c64565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b50813567ffffffffffffffff811115611cde57600080fd5b602083019150836020828501011115611cf657600080fd5b9250929050565b600080600080600060808688031215611d1557600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff811115611d4157600080fd5b611d4d88828901611cb4565b969995985093965092949392505050565b6000815180845260005b81811015611d8457602081850181015186830182015201611d68565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600081518084526020808501945080840160005b83811015611dfb5781516001600160a01b031687529582019590820190600101611dd6565b509495945050505050565b604081526000611e196040830185611d5e565b8281036020840152610ad48185611dc2565b60008060408385031215611e3e57600080fd5b82359150611e4e60208401611c64565b90509250929050565b60008060408385031215611e6a57600080fd5b50508035926020909101359150565b67ffffffffffffffff8116811461090757600080fd5b60008060008060008060a08789031215611ea857600080fd5b8635955060208701359450604087013593506060870135611ec881611e79565b9250608087013567ffffffffffffffff811115611ee457600080fd5b611ef089828a01611cb4565b979a9699509497509295939492505050565b60008060008060808587031215611f1857600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff80821115611f4657600080fd5b818801915088601f830112611f5a57600080fd5b813581811115611f6c57611f6c611b97565b611f9c847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611bc6565b91508082528984828501011115611fb257600080fd5b808484018584013760008482840101525080935050505092959194509250565b81518152602080830151908201526040810161068d565b602081526000610af56020830184611dc2565b6000806040838503121561200f57600080fd5b61201883611c64565b91506020830135801515811461202d57600080fd5b809150509250929050565b86815285602082015284604082015267ffffffffffffffff8416606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b8681528560208201526001600160a01b038516604082015260c0606082015260006120d960c0830186611dc2565b82810360808401526120eb8186611d5e565b905082810360a08401526120ff8185611d5e565b9998505050505050505050565b60006060828403121561211e57600080fd5b6040516060810181811067ffffffffffffffff8211171561214157612141611b97565b80604052508251815260208301516020820152604083015161216281611e79565b60408201529392505050565b8581526001600160a01b038516602082015260a06040820152600061219660a0830186611dc2565b82810360608401526121a88186611d5e565b9150508260808301529695505050505050565b6000602082840312156121cd57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8181038181111561068d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60ff831681526040602082015260006122886040830184611d5e565b94935050505056fea264697066735822122095dbed07b0f6460afc4214ae8929780044e0fae3559ba69bbf6c0f6e78d8c2e964736f6c63430008140033","runtime-code":"0x6080604052600436106101d85760003560e01c80639010d07c11610102578063b9b74b1811610095578063cb5038fb11610064578063cb5038fb146105b7578063d547741f146105d7578063eb53b44e146105f7578063f22ba23d1461061757600080fd5b8063b9b74b181461052e578063bc0d912c1461055b578063c313c80714610579578063ca15c8731461059757600080fd5b8063a9ac04b6116100d1578063a9ac04b6146104b9578063af8fcc8e146104d9578063b2494df3146104f9578063b70c40b31461050e57600080fd5b80639010d07c1461040657806391d148541461043e578063a1aa5d6814610482578063a217fddf146104a457600080fd5b80632f2ff15d1161017a57806351a308021161014957806351a308021461037157806368a6984714610391578063764ca1e8146103a45780637717a647146103c457600080fd5b80632f2ff15d146102fc57806336568abe1461031c5780633ccfd60b1461033c578063496774b11461035157600080fd5b80631c489e4f116101b65780631c489e4f14610254578063248a9ca314610296578063282be0e9146102c6578063287bc057146102d957600080fd5b806301ffc9a7146101dd5780630d32b505146102125780630fb5915614610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b55565b610637565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004611c15565b610693565b005b34801561024057600080fd5b5061023261024f366004611c80565b610766565b34801561026057600080fd5b506102887f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8481565b604051908152602001610209565b3480156102a257600080fd5b506102886102b1366004611c9b565b60009081526020819052604090206001015490565b6102326102d4366004611cfd565b61079d565b3480156102e557600080fd5b506102ee61085b565b604051610209929190611e06565b34801561030857600080fd5b50610232610317366004611e2b565b610876565b34801561032857600080fd5b50610232610337366004611e2b565b6108a1565b34801561034857600080fd5b506102326108f2565b34801561035d57600080fd5b5061023261036c366004611c80565b61090a565b34801561037d57600080fd5b5061023261038c366004611e57565b61099a565b61023261039f366004611e8f565b6109ce565b3480156103b057600080fd5b506102886103bf366004611f02565b610ab2565b3480156103d057600080fd5b50604080518082018252600080825260209182015281518083019092526003548252600454908201526040516102099190611fd2565b34801561041257600080fd5b50610426610421366004611e57565b610add565b6040516001600160a01b039091168152602001610209565b34801561044a57600080fd5b506101fd610459366004611e2b565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561048e57600080fd5b50610497610afc565b6040516102099190611fe9565b3480156104b057600080fd5b50610288600081565b3480156104c557600080fd5b506104266104d4366004611c9b565b610b0d565b3480156104e557600080fd5b506102326104f4366004611e2b565b610b68565b34801561050557600080fd5b50610497610ba5565b34801561051a57600080fd5b50610232610529366004611c80565b610bb1565b34801561053a57600080fd5b50610288610549366004611c9b565b60009081526005602052604090205490565b34801561056757600080fd5b506002546001600160a01b0316610426565b34801561058557600080fd5b50600a546001600160a01b0316610426565b3480156105a357600080fd5b506102886105b2366004611c9b565b610c6e565b3480156105c357600080fd5b506102326105d2366004611c80565b610c85565b3480156105e357600080fd5b506102326105f2366004611e2b565b610d79565b34801561060357600080fd5b50610232610612366004611c80565b610d9e565b34801561062357600080fd5b50610232610632366004611ffc565b610dd1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061068d575061068d82610e05565b92915050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846106bd81610e9c565b815115806106cd57506020820151155b1561071957815160208301516040517f8bdc31dd000000000000000000000000000000000000000000000000000000008152600481019290925260248201526044015b60405180910390fd5b81516003819055602080840151600481905560408051938452918301527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a15050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461079081610e9c565b61079982610ea6565b5050565b60006107f5863460405180604001604052808981526020018881525086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f6592505050565b602080820151604080840151845182518c81529485019390935267ffffffffffffffff169083015260608201529091507f2ef16db2691a32543ce5591798c4992f4cfbbcd446874f1437d99da53d600e7c906080015b60405180910390a1505050505050565b606080610866610fb5565b9150610870610ba5565b90509091565b60008281526020819052604090206001015461089181610e9c565b61089b8383610fd8565b50505050565b6001600160a01b03811633146108e3576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108ed828261100d565b505050565b60006108fd81610e9c565b610907334761103a565b50565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461093481610e9c565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e9060200161075a565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846109c481610e9c565b6108ed8383611103565b6109d7336111b9565b610a0f576040517f0578f695000000000000000000000000000000000000000000000000000000008152336004820152602401610710565b468603610a4b576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101879052602401610710565b6000868152600560205260409020548514610a9c576040517f327f41230000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604401610710565b610aaa8686868686866111c6565b505050505050565b6000610ad48560405180604001604052808781526020018681525084516111ff565b95945050505050565b6000828152600160205260408120610af59083611218565b9392505050565b6060610b086006611224565b905090565b600081815260056020526040902054806001600160a01b0381168114610b62576040517ff04c4a4500000000000000000000000000000000000000000000000000000000815260048101829052602401610710565b50919050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610b9281610e9c565b6108ed836001600160a01b038416611103565b6060610b086008611224565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610bdb81610e9c565b6000610be8600884611231565b905080610c2c576040517fb12a48e60000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a1505050565b600081815260016020526040812061068d90611246565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610caf81610e9c565b6001600160a01b038216610cef576040517fa8ce0c2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610cfc600884611250565b905080610d40576040517f856e38ac0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610c61565b600082815260208190526040902060010154610d9481610e9c565b61089b838361100d565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dc881610e9c565b61079982611265565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dfb81610e9c565b6108ed8383611398565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461068d565b6109078133611479565b610eaf816111b9565b610ef0576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b610efb8160006114e5565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b031603610907576109076000611265565b6040805160608101825260008082526020820181905291810182905290610f8b84611501565b600087815260056020526040902054909150610fab90879087848761152d565b9695505050505050565b6040805180820190915260035481526004546020820152606090610b0890611501565b600080610fe584846116fa565b90508015610af55760008481526001602052604090206110059084611250565b509392505050565b60008061101a84846117c2565b90508015610af55760008481526001602052604090206110059084611231565b80471015611076576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610710565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110c3576040519150601f19603f3d011682016040523d82523d6000602084013e6110c8565b606091505b50509050806108ed576040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46820361113f576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101839052602401610710565b600081900361117a576040517fe04fb69600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526005602052604080822083905551829184917f622d488f4fb24881af2fe5b552b249253a21e4a6fa77d12e69f61ee0fdfb9a319190a35050565b600061068d600683611863565b7fc5b07cf0d424748241636d3a67366b44ac88118c42bef024abcb7fd138df79a686868686868660405161084b96959493929190612038565b60008061120b84611501565b9050610ad4858285611885565b6000610af58383611969565b60606000610af583611993565b6000610af5836001600160a01b0384166119ef565b600061068d825490565b6000610af5836001600160a01b038416611ae2565b61126e816111b9565b15801561128357506001600160a01b03811615155b156112c5576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b6002546001600160a01b03166001600160a01b0316816001600160a01b031603611326576040517f56c309440000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c1699060200160405180910390a150565b6001600160a01b0382166113d8576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e1826111b9565b15611423576040517f4ea647680000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610710565b61142e8260016114e5565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156107995761079982611265565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610799576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610710565b80156114f6576108ed600683611250565b6108ed600683611231565b606061068d6001836040516020016115199190611fd2565b604051602081830303815290604052611b29565b6040805160608101825260008082526020820181905291810191909152600061155e6002546001600160a01b031690565b90506001600160a01b0381166115a0576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4687036115dc576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b600086900361161a576040517f9a3e6bd400000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b8447101561165d576040517f5b59cdf200000000000000000000000000000000000000000000000000000000815247600482015260248101869052604401610710565b806001600160a01b03166398939d28868989611681600a546001600160a01b031690565b611689610ba5565b8a8a6040518863ffffffff1660e01b81526004016116ac969594939291906120ab565b60606040518083038185885af11580156116ca573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116ef919061210c565b979650505050505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166117ba576000838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556117723390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161068d565b50600061068d565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16156117ba576000838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161068d565b6001600160a01b03811660009081526001830160205260408120541515610af5565b60008061189a6002546001600160a01b031690565b90506001600160a01b0381166118dc576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806001600160a01b0316637a1277db866118fe600a546001600160a01b031690565b611906610ba5565b88886040518663ffffffff1660e01b815260040161192895949392919061216e565b602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad491906121bb565b6000826000018281548110611980576119806121d4565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156119e357602002820191906000526020600020905b8154815260200190600101908083116119cf575b50505050509050919050565b60008181526001830160205260408120548015611ad8576000611a13600183612203565b8554909150600090611a2790600190612203565b9050808214611a8c576000866000018281548110611a4757611a476121d4565b9060005260206000200154905080876000018481548110611a6a57611a6a6121d4565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a9d57611a9d61223d565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061068d565b600091505061068d565b60008181526001830160205260408120546117ba5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561068d565b60608282604051602001611b3e92919061226c565b604051602081830303815290604052905092915050565b600060208284031215611b6757600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610af557600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c0d57611c0d611b97565b604052919050565b600060408284031215611c2757600080fd5b6040516040810181811067ffffffffffffffff82111715611c4a57611c4a611b97565b604052823581526020928301359281019290925250919050565b80356001600160a01b0381168114611c7b57600080fd5b919050565b600060208284031215611c9257600080fd5b610af582611c64565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b50813567ffffffffffffffff811115611cde57600080fd5b602083019150836020828501011115611cf657600080fd5b9250929050565b600080600080600060808688031215611d1557600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff811115611d4157600080fd5b611d4d88828901611cb4565b969995985093965092949392505050565b6000815180845260005b81811015611d8457602081850181015186830182015201611d68565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b600081518084526020808501945080840160005b83811015611dfb5781516001600160a01b031687529582019590820190600101611dd6565b509495945050505050565b604081526000611e196040830185611d5e565b8281036020840152610ad48185611dc2565b60008060408385031215611e3e57600080fd5b82359150611e4e60208401611c64565b90509250929050565b60008060408385031215611e6a57600080fd5b50508035926020909101359150565b67ffffffffffffffff8116811461090757600080fd5b60008060008060008060a08789031215611ea857600080fd5b8635955060208701359450604087013593506060870135611ec881611e79565b9250608087013567ffffffffffffffff811115611ee457600080fd5b611ef089828a01611cb4565b979a9699509497509295939492505050565b60008060008060808587031215611f1857600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff80821115611f4657600080fd5b818801915088601f830112611f5a57600080fd5b813581811115611f6c57611f6c611b97565b611f9c847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611bc6565b91508082528984828501011115611fb257600080fd5b808484018584013760008482840101525080935050505092959194509250565b81518152602080830151908201526040810161068d565b602081526000610af56020830184611dc2565b6000806040838503121561200f57600080fd5b61201883611c64565b91506020830135801515811461202d57600080fd5b809150509250929050565b86815285602082015284604082015267ffffffffffffffff8416606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b8681528560208201526001600160a01b038516604082015260c0606082015260006120d960c0830186611dc2565b82810360808401526120eb8186611d5e565b905082810360a08401526120ff8185611d5e565b9998505050505050505050565b60006060828403121561211e57600080fd5b6040516060810181811067ffffffffffffffff8211171561214157612141611b97565b80604052508251815260208301516020820152604083015161216281611e79565b60408201529392505050565b8581526001600160a01b038516602082015260a06040820152600061219660a0830186611dc2565b82810360608401526121a88186611d5e565b9150508260808301529695505050505050565b6000602082840312156121cd57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8181038181111561068d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60ff831681526040602082015260006122886040830184611d5e565b94935050505056fea264697066735822122095dbed07b0f6460afc4214ae8929780044e0fae3559ba69bbf6c0f6e78d8c2e964736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"77518:1995:0:-:0;;;77774:94;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;77809:5;68586:37;51136:4;77809:5;68586:10;:37::i;:::-;-1:-1:-1;77826:35:0::1;::::0;-1:-1:-1;67817:29:0::1;77855:5:::0;77826:10:::1;:35::i;:::-;;77774:94:::0;77518:1995;;66817:257;66903:4;;66934:31;66951:4;66957:7;66934:16;:31::i;:::-;66919:46;;66979:7;66975:69;;;67002:18;;;;:12;:18;;;;;:31;;67025:7;67002:22;:31::i;:::-;;66975:69;67060:7;-1:-1:-1;66817:257:0;;;;;:::o;55083:316::-;55160:4;51858:12;;;;;;;;;;;-1:-1:-1;;;;;51858:29:0;;;;;;;;;;;;55176:217;;55219:6;:12;;;;;;;;;;;-1:-1:-1;;;;;55219:29:0;;;;;;;;;:36;;-1:-1:-1;;55219:36:0;55251:4;55219:36;;;55301:12;18174:10;;18095:96;55301:12;-1:-1:-1;;;;;55274:40:0;55292:7;-1:-1:-1;;;;;55274:40:0;55286:4;55274:40;;;;;;;;;;-1:-1:-1;55335:4:0;55328:11;;55176:217;-1:-1:-1;55377:5:0;55370:12;;27619:150;27689:4;27712:50;27717:3;-1:-1:-1;;;;;27737:23:0;;21607:4;23663:21;;;:14;;;:21;;;;;;21623:321;;-1:-1:-1;21665:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;21847:18;;21823:21;;;:14;;;:21;;;;;;:42;;;;21879:11;;14:290:1;84:6;137:2;125:9;116:7;112:23;108:32;105:52;;;153:1;150;143:12;105:52;179:16;;-1:-1:-1;;;;;224:31:1;;214:42;;204:70;;270:1;267;260:12;14:290;77518:1995:0;;;;;;","srcMapRuntime":"77518:1995:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;65477:212;;;;;;;;;;-1:-1:-1;65477:212:0;;;;;:::i;:::-;;:::i;:::-;;;516:14:1;;509:22;491:41;;479:2;464:18;65477:212:0;;;;;;;;70336:419;;;;;;;;;;-1:-1:-1;70336:419:0;;;;;:::i;:::-;;:::i;:::-;;68865:122;;;;;;;;;;-1:-1:-1;68865:122:0;;;;;:::i;:::-;;:::i;67774:72::-;;;;;;;;;;;;67817:29;67774:72;;;;;2120:25:1;;;2108:2;2093:18;67774:72:0;1974:177:1;52714:120:0;;;;;;;;;;-1:-1:-1;52714:120:0;;;;;:::i;:::-;52779:7;52805:12;;;;;;;;;;:22;;;;52714:120;78161:528;;;;;;:::i;:::-;;:::i;57341:180::-;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;53130:136::-;;;;;;;;;;-1:-1:-1;53130:136:0;;;;;:::i;:::-;;:::i;54232:245::-;;;;;;;;;;-1:-1:-1;54232:245:0;;;;;:::i;:::-;;:::i;77955:136::-;;;;;;;;;;;;;:::i;70798:196::-;;;;;;;;;;-1:-1:-1;70798:196:0;;;;;:::i;:::-;;:::i;69201:146::-;;;;;;;;;;-1:-1:-1;69201:146:0;;;;;:::i;:::-;;:::i;56647:653::-;;;;;;:::i;:::-;;:::i;78775:324::-;;;;;;;;;;-1:-1:-1;78775:324:0;;;;;:::i;:::-;;:::i;71371:105::-;;;;;;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;71450:19:0;;;;;;;;71457:12;71450:19;;;;;;;;;71371:105;;;;;;:::i;66274:142::-;;;;;;;;;;-1:-1:-1;66274:142:0;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;8159:55:1;;;8141:74;;8129:2;8114:18;66274:142:0;7995:226:1;51758:136:0;;;;;;;;;;-1:-1:-1;51758:136:0;;;;;:::i;:::-;51835:4;51858:12;;;;;;;;;;;-1:-1:-1;;;;;51858:29:0;;;;;;;;;;;;;;;51758:136;71666:124;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;51091:49::-;;;;;;;;;;-1:-1:-1;51091:49:0;51136:4;51091:49;;72139:328;;;;;;;;;;-1:-1:-1;72139:328:0;;;;;:::i;:::-;;:::i;69390:168::-;;;;;;;;;;-1:-1:-1;69390:168:0;;;;;:::i;:::-;;:::i;72510:111::-;;;;;;;;;;;;;:::i;70015:278::-;;;;;;;;;;-1:-1:-1;70015:278:0;;;;;:::i;:::-;;:::i;71982:114::-;;;;;;;;;;-1:-1:-1;71982:114:0;;;;;:::i;:::-;72044:7;72070:19;;;:10;:19;;;;;;;71982:114;71833:106;;;;;;;;;;-1:-1:-1;71919:13:0;;-1:-1:-1;;;;;71919:13:0;71833:106;;71519:104;;;;;;;;;;-1:-1:-1;71599:17:0;;-1:-1:-1;;;;;71599:17:0;71519:104;;66584:131;;;;;;;;;;-1:-1:-1;66584:131:0;;;;;:::i;:::-;;:::i;69601:371::-;;;;;;;;;;-1:-1:-1;69601:371:0;;;;;:::i;:::-;;:::i;53546:138::-;;;;;;;;;;-1:-1:-1;53546:138:0;;;;;:::i;:::-;;:::i;69030:128::-;;;;;;;;;;-1:-1:-1;69030:128:0;;;;;:::i;:::-;;:::i;68673:149::-;;;;;;;;;;-1:-1:-1;68673:149:0;;;;;:::i;:::-;;:::i;65477:212::-;65562:4;65585:57;;;65600:42;65585:57;;:97;;;65646:36;65670:11;65646:23;:36::i;:::-;65578:104;65477:212;-1:-1:-1;;65477:212:0:o;70336:419::-;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;70440:27;;:32;;:67:::1;;-1:-1:-1::0;70476:26:0::1;::::0;::::1;::::0;:31;70440:67:::1;70436:193;;;70562:27:::0;;70591:26:::1;::::0;::::1;::::0;70530:88:::1;::::0;::::1;::::0;;::::1;::::0;::::1;9462:25:1::0;;;;9503:18;;;9496:34;9435:18;;70530:88:0::1;;;;;;;;70436:193;70638:24:::0;;:12:::1;:24:::0;;;::::1;::::0;;::::1;::::0;;;;;70677:71:::1;::::0;;9462:25:1;;;9503:18;;;9496:34;70677:71:0::1;::::0;9435:18:1;70677:71:0::1;;;;;;;;70336:419:::0;;:::o;68865:122::-;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;68959:21:::1;68973:6;68959:13;:21::i;:::-;68865:122:::0;;:::o;78161:528::-;78349:34;78386:207;78429:10;78465:9;78497:55;;;;;;;;78518:8;78497:55;;;;78540:10;78497:55;;;78575:7;;78386:207;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;78386:16:0;;-1:-1:-1;;;78386:207:0:i;:::-;78632:12;;;;;78646:15;;;;;78663:18;;78608:74;;9770:25:1;;;9811:18;;;9804:34;;;;9886:18;9874:31;9854:18;;;9847:59;9937:2;9922:18;;9915:34;78349:244:0;;-1:-1:-1;78608:74:0;;9757:3:1;9742:19;78608:74:0;;;;;;;;78339:350;78161:528;;;;;:::o;57341:180::-;57394:22;57418:24;57466:15;:13;:15::i;:::-;57454:27;;57501:13;:11;:13::i;:::-;57491:23;;57341:180;;:::o;53130:136::-;52779:7;52805:12;;;;;;;;;;:22;;;51368:16;51379:4;51368:10;:16::i;:::-;53234:25:::1;53245:4;53251:7;53234:10;:25::i;:::-;;53130:136:::0;;;:::o;54232:245::-;-1:-1:-1;;;;;54325:34:0;;18174:10;54325:34;54321:102;;54382:30;;;;;;;;;;;;;;54321:102;54433:37;54445:4;54451:18;54433:11;:37::i;:::-;;54232:245;;:::o;77955:136::-;51136:4;51368:16;51136:4;51368:10;:16::i;:::-;78023:61:::1;78049:10;78062:21;78023:17;:61::i;:::-;77955:136:::0;:::o;70798:196::-;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;70899:17:::1;:36:::0;;;::::1;-1:-1:-1::0;;;;;70899:36:0;::::1;::::0;;::::1;::::0;;;70950:37:::1;::::0;8141:74:1;;;70950:37:0::1;::::0;8129:2:1;8114:18;70950:37:0::1;7995:226:1::0;69201:146:0;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;69306:34:::1;69321:7;69330:9;69306:14;:34::i;56647:653::-:0;56861:31;56881:10;56861:19;:31::i;:::-;56856:116;;56915:46;;;;;56950:10;56915:46;;;8141:74:1;8114:18;;56915:46:0;7995:226:1;56856:116:0;56999:13;56985:10;:27;56981:103;;57035:38;;;;;;;;2120:25:1;;;2093:18;;57035:38:0;1974:177:1;56981:103:0;77116:4;77139:22;;;:10;:22;;;;;;:32;;57093:126;;57157:51;;;;;;;;9462:25:1;;;9503:18;;;9496:34;;;9435:18;;57157:51:0;9288:248:1;57093:126:0;57228:65;57244:10;57256:6;57264:7;57273:10;57285:7;;57228:15;:65::i;:::-;56647:653;;;;;;:::o;78775:324::-;78963:7;78993:99;79008:10;79020:55;;;;;;;;79041:8;79020:55;;;;79063:10;79020:55;;;79077:7;:14;78993;:99::i;:::-;78986:106;78775:324;-1:-1:-1;;;;;78775:324:0:o;66274:142::-;66355:7;66381:18;;;:12;:18;;;;;:28;;66403:5;66381:21;:28::i;:::-;66374:35;66274:142;-1:-1:-1;;;66274:142:0:o;71666:124::-;71721:16;71756:27;:18;:25;:27::i;:::-;71749:34;;71666:124;:::o;72139:328::-;72204:20;72256:19;;;:10;:19;;;;;;;-1:-1:-1;;;;;72342:29:0;;:44;;72338:123;;72409:41;;;;;;;;2120:25:1;;;2093:18;;72409:41:0;1974:177:1;72338:123:0;72226:241;72139:328;;;:::o;69390:168::-;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;69498:53:::1;69513:7:::0;-1:-1:-1;;;;;69522:26:0;::::1;69498:14;:53::i;72510:111::-:0;72555:16;72590:24;:15;:22;:24::i;70015:278::-;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;70106:12:::1;70121:30;:15;70144:6:::0;70121:22:::1;:30::i;:::-;70106:45;;70166:7;70161:83;;70196:37;::::0;::::1;::::0;;-1:-1:-1;;;;;8159:55:1;;70196:37:0::1;::::0;::::1;8141:74:1::0;8114:18;;70196:37:0::1;7995:226:1::0;70161:83:0::1;70258:28;::::0;-1:-1:-1;;;;;8159:55:1;;8141:74;;70258:28:0::1;::::0;8129:2:1;8114:18;70258:28:0::1;;;;;;;;70096:197;70015:278:::0;;:::o;66584:131::-;66655:7;66681:18;;;:12;:18;;;;;:27;;:25;:27::i;69601:371::-;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;-1:-1:-1;;;;;69693:20:0;::::1;69689:92;;69736:34;;;;;;;;;;;;;;69689:92;69790:10;69803:27;:15;69823:6:::0;69803:19:::1;:27::i;:::-;69790:40;;69845:5;69840:85;;69873:41;::::0;::::1;::::0;;-1:-1:-1;;;;;8159:55:1;;69873:41:0::1;::::0;::::1;8141:74:1::0;8114:18;;69873:41:0::1;7995:226:1::0;69840:85:0::1;69939:26;::::0;-1:-1:-1;;;;;8159:55:1;;8141:74;;69939:26:0::1;::::0;8129:2:1;8114:18;69939:26:0::1;7995:226:1::0;53546:138:0;52779:7;52805:12;;;;;;;;;;:22;;;51368:16;51379:4;51368:10;:16::i;:::-;53651:26:::1;53663:4;53669:7;53651:11;:26::i;69030:128::-:0;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;69127:24:::1;69144:6;69127:16;:24::i;68673:149::-:0;67817:29;51368:16;51379:4;51368:10;:16::i;:::-;68783:32:::1;68794:6;68802:12;68783:10;:32::i;51469:202::-:0;51554:4;51577:47;;;51592:32;51577:47;;:87;;-1:-1:-1;34379:25:0;34364:40;;;;51628:36;34265:146;52103:103;52169:30;52180:4;18174:10;52169;:30::i;58795:357::-;58858:27;58878:6;58858:19;:27::i;:::-;58853:108;;58908:42;;;;;-1:-1:-1;;;;;8159:55:1;;58908:42:0;;;8141:74:1;8114:18;;58908:42:0;7995:226:1;58853:108:0;58970:33;58989:6;58997:5;58970:18;:33::i;:::-;59018:31;;-1:-1:-1;;;;;8159:55:1;;8141:74;;59018:31:0;;8129:2:1;8114:18;59018:31:0;;;;;;;71919:13;;-1:-1:-1;;;;;71919:13:0;-1:-1:-1;;;;;59063:28:0;:6;-1:-1:-1;;;;;59063:28:0;;59059:87;;59107:28;59132:1;59107:16;:28::i;74915:405::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;75176:25:0;:7;:23;:25::i;:::-;75253:22;;;;:10;:22;;;;;;75146:55;;-1:-1:-1;75218:95:0;;75241:10;;75277;75146:55;75305:7;75218:22;:95::i;:::-;75211:102;74915:405;-1:-1:-1;;;;;;74915:405:0:o;76148:127::-;76236:30;;;;;;;;;:12;:30;;;;;;;;;76205:12;;76236:32;;:30;:32::i;66817:257::-;66903:4;66919:12;66934:31;66951:4;66957:7;66934:16;:31::i;:::-;66919:46;;66979:7;66975:69;;;67002:18;;;;:12;:18;;;;;:31;;67025:7;67002:22;:31::i;:::-;;67060:7;66817:257;-1:-1:-1;;;66817:257:0:o;67177:262::-;67264:4;67280:12;67295:32;67313:4;67319:7;67295:17;:32::i;:::-;67280:47;;67341:7;67337:72;;;67364:18;;;;:12;:18;;;;;:34;;67390:7;67364:25;:34::i;12706:331::-;12815:6;12791:21;:30;12787:109;;;12844:41;;;;;12879:4;12844:41;;;8141:74:1;8114:18;;12844:41:0;7995:226:1;12787:109:0;12907:12;12925:9;-1:-1:-1;;;;;12925:14:0;12947:6;12925:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12906:52;;;12973:7;12968:63;;13003:17;;;;;;;;;;;;;;73121:359;73215:13;73204:7;:24;73200:97;;73251:35;;;;;;;;2120:25:1;;;2093:18;;73251:35:0;1974:177:1;73200:97:0;73323:1;73310:14;;;73306:83;;73347:31;;;;;;;;;;;;;;73306:83;73398:19;;;;:10;:19;;;;;;:31;;;73444:29;73420:9;;73409:7;;73444:29;;73398:19;73444:29;73121:359;;:::o;77327:142::-;77404:4;77427:35;:18;77455:6;77427:27;:35::i;79219:292::-;79439:65;79455:10;79467:6;79475:7;79484:10;79496:7;;79439:65;;;;;;;;;;;:::i;75728:326::-;75895:7;75918:27;75948:25;:7;:23;:25::i;:::-;75918:55;;75990:57;76008:10;76020:14;76036:10;75990:17;:57::i;28877:156::-;28951:7;29001:22;29005:3;29017:5;29001:3;:22::i;29573:300::-;29636:16;29664:22;29689:19;29697:3;29689:7;:19::i;27937:156::-;28010:4;28033:53;28041:3;-1:-1:-1;;;;;28061:23:0;;28033:7;:53::i;28420:115::-;28483:7;28509:19;28517:3;23859:18;;23777:107;27619:150;27689:4;27712:50;27717:3;-1:-1:-1;;;;;27737:23:0;;27712:4;:50::i;59463:462::-;59601:27;59621:6;59601:19;:27::i;:::-;59600:28;:52;;;;-1:-1:-1;;;;;;59632:20:0;;;;59600:52;59596:132;;;59675:42;;;;;-1:-1:-1;;;;;8159:55:1;;59675:42:0;;;8141:74:1;8114:18;;59675:42:0;7995:226:1;59596:132:0;71919:13;;-1:-1:-1;;;;;71919:13:0;-1:-1:-1;;;;;59741:28:0;:6;-1:-1:-1;;;;;59741:28:0;;59737:108;;59792:42;;;;;-1:-1:-1;;;;;8159:55:1;;59792:42:0;;;8141:74:1;8114:18;;59792:42:0;7995:226:1;59737:108:0;73836:13;:22;;;;-1:-1:-1;;;;;73836:22:0;;;;;59895:23;;-1:-1:-1;;;;;8159:55:1;;8141:74;;59895:23:0;;8129:2:1;8114:18;59895:23:0;;;;;;;59463:462;:::o;58037:459::-;-1:-1:-1;;;;;58115:20:0;;58111:102;;58158:44;;;;;;;;;;;;;;58111:102;58226:27;58246:6;58226:19;:27::i;:::-;58222:106;;;58276:41;;;;;-1:-1:-1;;;;;8159:55:1;;58276:41:0;;;8141:74:1;8114:18;;58276:41:0;7995:226:1;58222:106:0;58337:32;58356:6;58364:4;58337:18;:32::i;:::-;58384:29;;-1:-1:-1;;;;;8159:55:1;;8141:74;;58384:29:0;;8129:2:1;8114:18;58384:29:0;;;;;;;58427:12;58423:67;;;58455:24;58472:6;58455:16;:24::i;52336:197::-;51835:4;51858:12;;;;;;;;;;;-1:-1:-1;;;;;51858:29:0;;;;;;;;;;;;52419:108;;52469:47;;;;;-1:-1:-1;;;;;11380:55:1;;52469:47:0;;;11362:74:1;11452:18;;;11445:34;;;11335:18;;52469:47:0;11188:297:1;74284:224:0;74374:7;74370:132;;;74397:30;:18;74420:6;74397:22;:30::i;74370:132::-;74458:33;:18;74484:6;74458:25;:33::i;6650:167::-;6724:12;6755:55;5683:1;6801:7;6790:19;;;;;;;;:::i;:::-;;;;;;;;;;;;;6755:22;:55::i;61622:973::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;61886:14:0;61903:18;71919:13;;-1:-1:-1;;;;;71919:13:0;;71833:106;61903:18;61886:35;-1:-1:-1;;;;;;61935:20:0;;61931:102;;61978:44;;;;;;;;;;;;;;61931:102;62060:13;62046:10;:27;62042:103;;62096:38;;;;;;;;2120:25:1;;;2093:18;;62096:38:0;1974:177:1;62042:103:0;62170:1;62158:13;;;62154:92;;62194:41;;;;;;;;2120:25:1;;;2093:18;;62194:41:0;1974:177:1;62154:92:0;62283:10;62259:21;:34;62255:155;;;62316:83;;;;;62354:21;62316:83;;;9462:25:1;9503:18;;;9496:34;;;9435:18;;62316:83:0;9288:248:1;62255:155:0;62446:6;-1:-1:-1;;;;;62426:42:0;;62476:10;62501;62513:8;62523:22;71599:17;;-1:-1:-1;;;;;71599:17:0;;71519:104;62523:22;62547:13;:11;:13::i;:::-;62562:7;62571;62426:162;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;62419:169;61622:973;-1:-1:-1;;;;;;;61622:973:0:o;55083:316::-;55160:4;51858:12;;;;;;;;;;;-1:-1:-1;;;;;51858:29:0;;;;;;;;;;;;55176:217;;55219:6;:12;;;;;;;;;;;-1:-1:-1;;;;;55219:29:0;;;;;;;;;:36;;;;55251:4;55219:36;;;55301:12;18174:10;;18095:96;55301:12;-1:-1:-1;;;;;55274:40:0;55292:7;-1:-1:-1;;;;;55274:40:0;55286:4;55274:40;;;;;;;;;;-1:-1:-1;55335:4:0;55328:11;;55176:217;-1:-1:-1;55377:5:0;55370:12;;55634:317;55712:4;51858:12;;;;;;;;;;;-1:-1:-1;;;;;51858:29:0;;;;;;;;;;;;55728:217;;;55802:5;55770:12;;;;;;;;;;;-1:-1:-1;;;;;55770:29:0;;;;;;;;;;:37;;;;;;55826:40;18174:10;;55770:12;;55826:40;;55802:5;55826:40;-1:-1:-1;55887:4:0;55880:11;;28174:165;-1:-1:-1;;;;;28307:23:0;;28254:4;23663:21;;;:14;;;:21;;;;;;:26;;28277:55;23567:129;63301:497;63467:7;63490:14;63507:18;71919:13;;-1:-1:-1;;;;;71919:13:0;;71833:106;63507:18;63490:35;-1:-1:-1;;;;;;63539:20:0;;63535:102;;63582:44;;;;;;;;;;;;;;63535:102;63673:6;-1:-1:-1;;;;;63653:44:0;;63711:10;63723:22;71599:17;;-1:-1:-1;;;;;71599:17:0;;71519:104;63723:22;63747:13;:11;:13::i;:::-;63762:7;63771:10;63653:138;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;24226:118::-;24293:7;24319:3;:11;;24331:5;24319:18;;;;;;;;:::i;:::-;;;;;;;;;24312:25;;24226:118;;;;:::o;24884:109::-;24940:16;24975:3;:11;;24968:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24884:109;;;:::o;22118:1368::-;22184:4;22313:21;;;:14;;;:21;;;;;;22349:13;;22345:1135;;22716:18;22737:12;22748:1;22737:8;:12;:::i;:::-;22783:18;;22716:33;;-1:-1:-1;22763:17:0;;22783:22;;22804:1;;22783:22;:::i;:::-;22763:42;;22838:9;22824:10;:23;22820:378;;22867:17;22887:3;:11;;22899:9;22887:22;;;;;;;;:::i;:::-;;;;;;;;;22867:42;;23034:9;23008:3;:11;;23020:10;23008:23;;;;;;;;:::i;:::-;;;;;;;;;;;;:35;;;;23147:25;;;:14;;;:25;;;;;:36;;;22820:378;23276:17;;:3;;:17;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;23379:3;:14;;:21;23394:5;23379:21;;;;;;;;;;;23372:28;;;23422:4;23415:11;;;;;;;22345:1135;23464:5;23457:12;;;;;21544:406;21607:4;23663:21;;;:14;;;:21;;;;;;21623:321;;-1:-1:-1;21665:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;21847:18;;21823:21;;;:14;;;:21;;;;;;:42;;;;21879:11;;5917:158;6009:12;6051:7;6060;6040:28;;;;;;;;;:::i;:::-;;;;;;;;;;;;;6033:35;;5917:158;;;;:::o;14:332:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;180:9;167:23;230:66;223:5;219:78;212:5;209:89;199:117;;312:1;309;302:12;543:184;595:77;592:1;585:88;692:4;689:1;682:15;716:4;713:1;706:15;732:334;803:2;797:9;859:2;849:13;;864:66;845:86;833:99;;962:18;947:34;;983:22;;;944:62;941:88;;;1009:18;;:::i;:::-;1045:2;1038:22;732:334;;-1:-1:-1;732:334:1:o;1071:506::-;1157:6;1210:2;1198:9;1189:7;1185:23;1181:32;1178:52;;;1226:1;1223;1216:12;1178:52;1259:2;1253:9;1301:2;1293:6;1289:15;1370:6;1358:10;1355:22;1334:18;1322:10;1319:34;1316:62;1313:88;;;1381:18;;:::i;:::-;1417:2;1410:22;1456:23;;1441:39;;1541:2;1526:18;;;1513:32;1496:15;;;1489:57;;;;-1:-1:-1;1448:6:1;1071:506;-1:-1:-1;1071:506:1:o;1582:196::-;1650:20;;-1:-1:-1;;;;;1699:54:1;;1689:65;;1679:93;;1768:1;1765;1758:12;1679:93;1582:196;;;:::o;1783:186::-;1842:6;1895:2;1883:9;1874:7;1870:23;1866:32;1863:52;;;1911:1;1908;1901:12;1863:52;1934:29;1953:9;1934:29;:::i;2156:180::-;2215:6;2268:2;2256:9;2247:7;2243:23;2239:32;2236:52;;;2284:1;2281;2274:12;2236:52;-1:-1:-1;2307:23:1;;2156:180;-1:-1:-1;2156:180:1:o;2341:347::-;2392:8;2402:6;2456:3;2449:4;2441:6;2437:17;2433:27;2423:55;;2474:1;2471;2464:12;2423:55;-1:-1:-1;2497:20:1;;2540:18;2529:30;;2526:50;;;2572:1;2569;2562:12;2526:50;2609:4;2601:6;2597:17;2585:29;;2661:3;2654:4;2645:6;2637;2633:19;2629:30;2626:39;2623:59;;;2678:1;2675;2668:12;2623:59;2341:347;;;;;:::o;2693:614::-;2790:6;2798;2806;2814;2822;2875:3;2863:9;2854:7;2850:23;2846:33;2843:53;;;2892:1;2889;2882:12;2843:53;2928:9;2915:23;2905:33;;2985:2;2974:9;2970:18;2957:32;2947:42;;3036:2;3025:9;3021:18;3008:32;2998:42;;3091:2;3080:9;3076:18;3063:32;3118:18;3110:6;3107:30;3104:50;;;3150:1;3147;3140:12;3104:50;3189:58;3239:7;3230:6;3219:9;3215:22;3189:58;:::i;:::-;2693:614;;;;-1:-1:-1;2693:614:1;;-1:-1:-1;3266:8:1;;3163:84;2693:614;-1:-1:-1;;;2693:614:1:o;3312:481::-;3353:3;3391:5;3385:12;3418:6;3413:3;3406:19;3443:1;3453:162;3467:6;3464:1;3461:13;3453:162;;;3529:4;3585:13;;;3581:22;;3575:29;3557:11;;;3553:20;;3546:59;3482:12;3453:162;;;3457:3;3660:1;3653:4;3644:6;3639:3;3635:16;3631:27;3624:38;3782:4;3712:66;3707:2;3699:6;3695:15;3691:88;3686:3;3682:98;3678:109;3671:116;;;3312:481;;;;:::o;3798:484::-;3851:3;3889:5;3883:12;3916:6;3911:3;3904:19;3942:4;3971:2;3966:3;3962:12;3955:19;;4008:2;4001:5;3997:14;4029:1;4039:218;4053:6;4050:1;4047:13;4039:218;;;4118:13;;-1:-1:-1;;;;;4114:62:1;4102:75;;4197:12;;;;4232:15;;;;4075:1;4068:9;4039:218;;;-1:-1:-1;4273:3:1;;3798:484;-1:-1:-1;;;;;3798:484:1:o;4287:421::-;4512:2;4501:9;4494:21;4475:4;4538:44;4578:2;4567:9;4563:18;4555:6;4538:44;:::i;:::-;4630:9;4622:6;4618:22;4613:2;4602:9;4598:18;4591:50;4658:44;4695:6;4687;4658:44;:::i;4713:254::-;4781:6;4789;4842:2;4830:9;4821:7;4817:23;4813:32;4810:52;;;4858:1;4855;4848:12;4810:52;4894:9;4881:23;4871:33;;4923:38;4957:2;4946:9;4942:18;4923:38;:::i;:::-;4913:48;;4713:254;;;;;:::o;4972:248::-;5040:6;5048;5101:2;5089:9;5080:7;5076:23;5072:32;5069:52;;;5117:1;5114;5107:12;5069:52;-1:-1:-1;;5140:23:1;;;5210:2;5195:18;;;5182:32;;-1:-1:-1;4972:248:1:o;5225:129::-;5310:18;5303:5;5299:30;5292:5;5289:41;5279:69;;5344:1;5341;5334:12;5359:748;5464:6;5472;5480;5488;5496;5504;5557:3;5545:9;5536:7;5532:23;5528:33;5525:53;;;5574:1;5571;5564:12;5525:53;5610:9;5597:23;5587:33;;5667:2;5656:9;5652:18;5639:32;5629:42;;5718:2;5707:9;5703:18;5690:32;5680:42;;5772:2;5761:9;5757:18;5744:32;5785:30;5809:5;5785:30;:::i;:::-;5834:5;-1:-1:-1;5890:3:1;5875:19;;5862:33;5918:18;5907:30;;5904:50;;;5950:1;5947;5940:12;5904:50;5989:58;6039:7;6030:6;6019:9;6015:22;5989:58;:::i;:::-;5359:748;;;;-1:-1:-1;5359:748:1;;-1:-1:-1;5359:748:1;;6066:8;;5359:748;-1:-1:-1;;;5359:748:1:o;6112:1027::-;6207:6;6215;6223;6231;6284:3;6272:9;6263:7;6259:23;6255:33;6252:53;;;6301:1;6298;6291:12;6252:53;6337:9;6324:23;6314:33;;6366:2;6415;6404:9;6400:18;6387:32;6377:42;;6466:2;6455:9;6451:18;6438:32;6428:42;;6521:2;6510:9;6506:18;6493:32;6544:18;6585:2;6577:6;6574:14;6571:34;;;6601:1;6598;6591:12;6571:34;6639:6;6628:9;6624:22;6614:32;;6684:7;6677:4;6673:2;6669:13;6665:27;6655:55;;6706:1;6703;6696:12;6655:55;6742:2;6729:16;6764:2;6760;6757:10;6754:36;;;6770:18;;:::i;:::-;6812:112;6920:2;6851:66;6844:4;6840:2;6836:13;6832:86;6828:95;6812:112;:::i;:::-;6799:125;;6947:2;6940:5;6933:17;6987:7;6982:2;6977;6973;6969:11;6965:20;6962:33;6959:53;;;7008:1;7005;6998:12;6959:53;7063:2;7058;7054;7050:11;7045:2;7038:5;7034:14;7021:45;7107:1;7102:2;7097;7090:5;7086:14;7082:23;7075:34;;7128:5;7118:15;;;;;6112:1027;;;;;;;:::o;7483:254::-;7403:12;;7391:25;;7465:4;7454:16;;;7448:23;7432:14;;;7425:47;7671:2;7656:18;;7683:48;7326:152;8226:261;8405:2;8394:9;8387:21;8368:4;8425:56;8477:2;8466:9;8462:18;8454:6;8425:56;:::i;8936:347::-;9001:6;9009;9062:2;9050:9;9041:7;9037:23;9033:32;9030:52;;;9078:1;9075;9068:12;9030:52;9101:29;9120:9;9101:29;:::i;:::-;9091:39;;9180:2;9169:9;9165:18;9152:32;9227:5;9220:13;9213:21;9206:5;9203:32;9193:60;;9249:1;9246;9239:12;9193:60;9272:5;9262:15;;;8936:347;;;;;:::o;10423:760::-;10690:6;10679:9;10672:25;10733:6;10728:2;10717:9;10713:18;10706:34;10776:6;10771:2;10760:9;10756:18;10749:34;10831:18;10823:6;10819:31;10814:2;10803:9;10799:18;10792:59;10888:3;10882;10871:9;10867:19;10860:32;10929:6;10923:3;10912:9;10908:19;10901:35;10987:6;10979;10973:3;10962:9;10958:19;10945:49;11044:1;11014:22;;;11038:3;11010:32;;;11003:43;;;;11098:2;11086:15;;;11103:66;11082:88;11067:104;11063:114;;10423:760;-1:-1:-1;;;;;10423:760:1:o;11747:847::-;12102:6;12091:9;12084:25;12145:6;12140:2;12129:9;12125:18;12118:34;-1:-1:-1;;;;;12192:6:1;12188:55;12183:2;12172:9;12168:18;12161:83;12280:3;12275:2;12264:9;12260:18;12253:31;12065:4;12307:57;12359:3;12348:9;12344:19;12336:6;12307:57;:::i;:::-;12413:9;12405:6;12401:22;12395:3;12384:9;12380:19;12373:51;12447:32;12472:6;12464;12447:32;:::i;:::-;12433:46;;12528:9;12520:6;12516:22;12510:3;12499:9;12495:19;12488:51;12556:32;12581:6;12573;12556:32;:::i;:::-;12548:40;11747:847;-1:-1:-1;;;;;;;;;11747:847:1:o;12599:641::-;12709:6;12762:2;12750:9;12741:7;12737:23;12733:32;12730:52;;;12778:1;12775;12768:12;12730:52;12811:2;12805:9;12853:2;12845:6;12841:15;12922:6;12910:10;12907:22;12886:18;12874:10;12871:34;12868:62;12865:88;;;12933:18;;:::i;:::-;12973:10;12969:2;12962:22;;13014:9;13008:16;13000:6;12993:32;13079:2;13068:9;13064:18;13058:25;13053:2;13045:6;13041:15;13034:50;13127:2;13116:9;13112:18;13106:25;13140:30;13164:5;13140:30;:::i;:::-;13198:2;13186:15;;13179:30;13190:6;12599:641;-1:-1:-1;;;12599:641:1:o;13245:686::-;13554:6;13543:9;13536:25;-1:-1:-1;;;;;13601:6:1;13597:55;13592:2;13581:9;13577:18;13570:83;13689:3;13684:2;13673:9;13669:18;13662:31;13517:4;13716:57;13768:3;13757:9;13753:19;13745:6;13716:57;:::i;:::-;13821:9;13813:6;13809:22;13804:2;13793:9;13789:18;13782:50;13849:32;13874:6;13866;13849:32;:::i;:::-;13841:40;;;13918:6;13912:3;13901:9;13897:19;13890:35;13245:686;;;;;;;;:::o;13936:184::-;14006:6;14059:2;14047:9;14038:7;14034:23;14030:32;14027:52;;;14075:1;14072;14065:12;14027:52;-1:-1:-1;14098:16:1;;13936:184;-1:-1:-1;13936:184:1:o;14125:::-;14177:77;14174:1;14167:88;14274:4;14271:1;14264:15;14298:4;14295:1;14288:15;14314:282;14381:9;;;14402:11;;;14399:191;;;14446:77;14443:1;14436:88;14547:4;14544:1;14537:15;14575:4;14572:1;14565:15;14601:184;14653:77;14650:1;14643:88;14750:4;14747:1;14740:15;14774:4;14771:1;14764:15;14790:295;14973:4;14965:6;14961:17;14950:9;14943:36;15015:2;15010;14999:9;14995:18;14988:30;14924:4;15035:44;15075:2;15064:9;15060:18;15052:6;15035:44;:::i;:::-;15027:52;14790:295;-1:-1:-1;;;;14790:295:1:o","abiDefinition":[{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__AlreadyLatestClient","type":"error"},{"inputs":[],"name":"InterchainApp__AppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainApp__BalanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__ClientAlreadyAdded","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"InterchainApp__InvalidAppConfig","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__NotEVMLinkedApp","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__ReceiverNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__SameChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"sender","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"MessageReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"dstChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"MessageSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"linkedAppEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"getMessageFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"sendMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"appConfig","type":"tuple"}],"name":"setAppConfigV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"IC_GOVERNOR_ROLE()":{"notice":"Role to manage the Interchain setup of the app."},"addInterchainClient(address,bool)":{"notice":"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app."},"addTrustedModule(address)":{"notice":"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages."},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getAppConfigV1()":{"notice":"Returns the app config for the current app: requiredResponses and optimisticPeriod."},"getExecutionService()":{"notice":"Returns the address of the Execution Service used by this app for sending messages."},"getInterchainClients()":{"notice":"Returns the list of Interchain Clients allowed to send messages to this app."},"getLatestInterchainClient()":{"notice":"Returns the address of the latest interchain client. This address is used for sending messages from this app."},"getLinkedApp(uint256)":{"notice":"Returns the linked app address (as bytes32) for the given chain ID."},"getLinkedAppEVM(uint256)":{"notice":"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address."},"getMessageFee(uint256,uint256,uint256,bytes)":{"notice":"Returns the fee required to send a message using `sendMessage`."},"getModules()":{"notice":"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."},"linkRemoteApp(uint256,bytes32)":{"notice":"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain."},"linkRemoteAppEVM(uint256,address)":{"notice":"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter."},"removeInterchainClient(address)":{"notice":"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address."},"removeTrustedModule(address)":{"notice":"Allows the owner to remove the module from the trusted modules set."},"sendMessage(uint256,uint256,uint256,bytes)":{"notice":"Sends a basic message to the destination chain."},"setAppConfigV1((uint256,uint256))":{"notice":"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final"},"setExecutionService(address)":{"notice":"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee."},"setLatestInterchainClient(address)":{"notice":"Allows the owner to set the address of the latest interchain client."},"withdraw()":{"notice":"Allows the Admin to withdraw the native asset from the contract."}},"version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"AddressInsufficientBalance(address)":[{"details":"The ETH balance of the account is not enough to perform the operation."}],"FailedInnerCall()":[{"details":"A call to an address target failed. The target may have reverted."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"addInterchainClient(address,bool)":{"params":{"client":"The address of the interchain client to add.","updateLatest":"Whether to set the latest client to this one."}},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getLinkedAppEVM(uint256)":{"details":"Will revert if the linked app address is not an EVM address."},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"linkRemoteApp(uint256,bytes32)":{"params":{"chainId":"The remote chain ID.","remoteApp":"The address of the remote app to link."}},"removeInterchainClient(address)":{"params":{"client":"The address of the interchain client to remove."}},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"setLatestInterchainClient(address)":{"details":"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.","params":{"client":"The address of the latest interchain client."}},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__AlreadyLatestClient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__AppZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__BalanceTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__ClientAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__InterchainClientZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__InvalidAppConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__ModuleZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"linkedApp\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__NotEVMLinkedApp\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"InterchainApp__NotInterchainClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__ReceiverNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__SenderNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"AppConfigV1Set\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"AppLinked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"ExecutionServiceSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"MessageReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"MessageSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleRemoved\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"updateLatest\",\"type\":\"bool\"}],\"name\":\"addInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"addTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAppConfigV1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExecutionService\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInterchainClients\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestInterchainClient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedApp\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedAppEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedAppEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"getMessageFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"linkRemoteApp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"remoteApp\",\"type\":\"address\"}],\"name\":\"linkRemoteAppEVM\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"removeInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"removeTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"sendMessage\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"appConfig\",\"type\":\"tuple\"}],\"name\":\"setAppConfigV1\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"setExecutionService\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"setLatestInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"addInterchainClient(address,bool)\":{\"params\":{\"client\":\"The address of the interchain client to add.\",\"updateLatest\":\"Whether to set the latest client to this one.\"}},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getLinkedAppEVM(uint256)\":{\"details\":\"Will revert if the linked app address is not an EVM address.\"},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"linkRemoteApp(uint256,bytes32)\":{\"params\":{\"chainId\":\"The remote chain ID.\",\"remoteApp\":\"The address of the remote app to link.\"}},\"removeInterchainClient(address)\":{\"params\":{\"client\":\"The address of the interchain client to remove.\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setLatestInterchainClient(address)\":{\"details\":\"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.\",\"params\":{\"client\":\"The address of the latest interchain client.\"}},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"IC_GOVERNOR_ROLE()\":{\"notice\":\"Role to manage the Interchain setup of the app.\"},\"addInterchainClient(address,bool)\":{\"notice\":\"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app.\"},\"addTrustedModule(address)\":{\"notice\":\"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages.\"},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getAppConfigV1()\":{\"notice\":\"Returns the app config for the current app: requiredResponses and optimisticPeriod.\"},\"getExecutionService()\":{\"notice\":\"Returns the address of the Execution Service used by this app for sending messages.\"},\"getInterchainClients()\":{\"notice\":\"Returns the list of Interchain Clients allowed to send messages to this app.\"},\"getLatestInterchainClient()\":{\"notice\":\"Returns the address of the latest interchain client. This address is used for sending messages from this app.\"},\"getLinkedApp(uint256)\":{\"notice\":\"Returns the linked app address (as bytes32) for the given chain ID.\"},\"getLinkedAppEVM(uint256)\":{\"notice\":\"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\"},\"getMessageFee(uint256,uint256,uint256,bytes)\":{\"notice\":\"Returns the fee required to send a message using `sendMessage`.\"},\"getModules()\":{\"notice\":\"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"},\"linkRemoteApp(uint256,bytes32)\":{\"notice\":\"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain.\"},\"linkRemoteAppEVM(uint256,address)\":{\"notice\":\"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\"},\"removeInterchainClient(address)\":{\"notice\":\"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address.\"},\"removeTrustedModule(address)\":{\"notice\":\"Allows the owner to remove the module from the trusted modules set.\"},\"sendMessage(uint256,uint256,uint256,bytes)\":{\"notice\":\"Sends a basic message to the destination chain.\"},\"setAppConfigV1((uint256,uint256))\":{\"notice\":\"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final\"},\"setExecutionService(address)\":{\"notice\":\"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee.\"},\"setLatestInterchainClient(address)\":{\"notice\":\"Allows the owner to set the address of the latest interchain client.\"},\"withdraw()\":{\"notice\":\"Allows the Admin to withdraw the native asset from the contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"ExampleAppV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","IC_GOVERNOR_ROLE()":"1c489e4f","addInterchainClient(address,bool)":"f22ba23d","addTrustedModule(address)":"cb5038fb","appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getAppConfigV1()":"7717a647","getExecutionService()":"c313c807","getInterchainClients()":"a1aa5d68","getLatestInterchainClient()":"bc0d912c","getLinkedApp(uint256)":"b9b74b18","getLinkedAppEVM(uint256)":"a9ac04b6","getMessageFee(uint256,uint256,uint256,bytes)":"764ca1e8","getModules()":"b2494df3","getReceivingConfig()":"287bc057","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","linkRemoteApp(uint256,bytes32)":"51a30802","linkRemoteAppEVM(uint256,address)":"af8fcc8e","removeInterchainClient(address)":"0fb59156","removeTrustedModule(address)":"b70c40b3","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","sendMessage(uint256,uint256,uint256,bytes)":"282be0e9","setAppConfigV1((uint256,uint256))":"0d32b505","setExecutionService(address)":"496774b1","setLatestInterchainClient(address)":"eb53b44e","supportsInterface(bytes4)":"01ffc9a7","withdraw()":"3ccfd60b"}},"solidity/ExampleAppV1.sol:IAccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"External interface of AccessControl declared to support ERC165 detection.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"External interface of AccessControl declared to support ERC165 detection.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IAccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"solidity/ExampleAppV1.sol:IAccessControlEnumerable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"External interface of AccessControlEnumerable declared to support ERC165 detection.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"External interface of AccessControlEnumerable declared to support ERC165 detection.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IAccessControlEnumerable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"solidity/ExampleAppV1.sol:ICAppV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__AlreadyLatestClient","type":"error"},{"inputs":[],"name":"InterchainApp__AppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainApp__BalanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__ClientAlreadyAdded","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"InterchainApp__InvalidAppConfig","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__NotEVMLinkedApp","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__ReceiverNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__SameChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"linkedAppEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"appConfig","type":"tuple"}],"name":"setAppConfigV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"IC_GOVERNOR_ROLE()":{"notice":"Role to manage the Interchain setup of the app."},"addInterchainClient(address,bool)":{"notice":"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app."},"addTrustedModule(address)":{"notice":"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages."},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getAppConfigV1()":{"notice":"Returns the app config for the current app: requiredResponses and optimisticPeriod."},"getExecutionService()":{"notice":"Returns the address of the Execution Service used by this app for sending messages."},"getInterchainClients()":{"notice":"Returns the list of Interchain Clients allowed to send messages to this app."},"getLatestInterchainClient()":{"notice":"Returns the address of the latest interchain client. This address is used for sending messages from this app."},"getLinkedApp(uint256)":{"notice":"Returns the linked app address (as bytes32) for the given chain ID."},"getLinkedAppEVM(uint256)":{"notice":"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address."},"getModules()":{"notice":"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."},"linkRemoteApp(uint256,bytes32)":{"notice":"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain."},"linkRemoteAppEVM(uint256,address)":{"notice":"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter."},"removeInterchainClient(address)":{"notice":"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address."},"removeTrustedModule(address)":{"notice":"Allows the owner to remove the module from the trusted modules set."},"setAppConfigV1((uint256,uint256))":{"notice":"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final"},"setExecutionService(address)":{"notice":"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee."},"setLatestInterchainClient(address)":{"notice":"Allows the owner to set the address of the latest interchain client."}},"version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"addInterchainClient(address,bool)":{"params":{"client":"The address of the interchain client to add.","updateLatest":"Whether to set the latest client to this one."}},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getLinkedAppEVM(uint256)":{"details":"Will revert if the linked app address is not an EVM address."},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"linkRemoteApp(uint256,bytes32)":{"params":{"chainId":"The remote chain ID.","remoteApp":"The address of the remote app to link."}},"removeInterchainClient(address)":{"params":{"client":"The address of the interchain client to remove."}},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"setLatestInterchainClient(address)":{"details":"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.","params":{"client":"The address of the latest interchain client."}},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"stateVariables":{"_appConfigV1":{"details":"Required responses and optimistic period for the module responses."},"_executionService":{"details":"Execution Service to use for sending messages."},"_interchainClients":{"details":"Interchain Clients allowed to send messages to this app."},"_latestClient":{"details":"Address of the latest Interchain Client, used for sending messages."},"_linkedApp":{"details":"Address of the linked app deployed on the remote chain."},"_trustedModules":{"details":"Trusted Interchain modules."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__AlreadyLatestClient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__AppZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__BalanceTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__ClientAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__InterchainClientZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__InvalidAppConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__ModuleZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"linkedApp\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__NotEVMLinkedApp\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"InterchainApp__NotInterchainClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__ReceiverNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__SenderNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"AppConfigV1Set\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"AppLinked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"ExecutionServiceSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleRemoved\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"updateLatest\",\"type\":\"bool\"}],\"name\":\"addInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"addTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAppConfigV1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExecutionService\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInterchainClients\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestInterchainClient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedApp\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedAppEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedAppEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"linkRemoteApp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"remoteApp\",\"type\":\"address\"}],\"name\":\"linkRemoteAppEVM\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"removeInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"removeTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"appConfig\",\"type\":\"tuple\"}],\"name\":\"setAppConfigV1\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"setExecutionService\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"setLatestInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"addInterchainClient(address,bool)\":{\"params\":{\"client\":\"The address of the interchain client to add.\",\"updateLatest\":\"Whether to set the latest client to this one.\"}},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getLinkedAppEVM(uint256)\":{\"details\":\"Will revert if the linked app address is not an EVM address.\"},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"linkRemoteApp(uint256,bytes32)\":{\"params\":{\"chainId\":\"The remote chain ID.\",\"remoteApp\":\"The address of the remote app to link.\"}},\"removeInterchainClient(address)\":{\"params\":{\"client\":\"The address of the interchain client to remove.\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setLatestInterchainClient(address)\":{\"details\":\"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.\",\"params\":{\"client\":\"The address of the latest interchain client.\"}},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"stateVariables\":{\"_appConfigV1\":{\"details\":\"Required responses and optimistic period for the module responses.\"},\"_executionService\":{\"details\":\"Execution Service to use for sending messages.\"},\"_interchainClients\":{\"details\":\"Interchain Clients allowed to send messages to this app.\"},\"_latestClient\":{\"details\":\"Address of the latest Interchain Client, used for sending messages.\"},\"_linkedApp\":{\"details\":\"Address of the linked app deployed on the remote chain.\"},\"_trustedModules\":{\"details\":\"Trusted Interchain modules.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"IC_GOVERNOR_ROLE()\":{\"notice\":\"Role to manage the Interchain setup of the app.\"},\"addInterchainClient(address,bool)\":{\"notice\":\"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app.\"},\"addTrustedModule(address)\":{\"notice\":\"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages.\"},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getAppConfigV1()\":{\"notice\":\"Returns the app config for the current app: requiredResponses and optimisticPeriod.\"},\"getExecutionService()\":{\"notice\":\"Returns the address of the Execution Service used by this app for sending messages.\"},\"getInterchainClients()\":{\"notice\":\"Returns the list of Interchain Clients allowed to send messages to this app.\"},\"getLatestInterchainClient()\":{\"notice\":\"Returns the address of the latest interchain client. This address is used for sending messages from this app.\"},\"getLinkedApp(uint256)\":{\"notice\":\"Returns the linked app address (as bytes32) for the given chain ID.\"},\"getLinkedAppEVM(uint256)\":{\"notice\":\"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\"},\"getModules()\":{\"notice\":\"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"},\"linkRemoteApp(uint256,bytes32)\":{\"notice\":\"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain.\"},\"linkRemoteAppEVM(uint256,address)\":{\"notice\":\"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\"},\"removeInterchainClient(address)\":{\"notice\":\"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address.\"},\"removeTrustedModule(address)\":{\"notice\":\"Allows the owner to remove the module from the trusted modules set.\"},\"setAppConfigV1((uint256,uint256))\":{\"notice\":\"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final\"},\"setExecutionService(address)\":{\"notice\":\"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee.\"},\"setLatestInterchainClient(address)\":{\"notice\":\"Allows the owner to set the address of the latest interchain client.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"ICAppV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","IC_GOVERNOR_ROLE()":"1c489e4f","addInterchainClient(address,bool)":"f22ba23d","addTrustedModule(address)":"cb5038fb","appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getAppConfigV1()":"7717a647","getExecutionService()":"c313c807","getInterchainClients()":"a1aa5d68","getLatestInterchainClient()":"bc0d912c","getLinkedApp(uint256)":"b9b74b18","getLinkedAppEVM(uint256)":"a9ac04b6","getModules()":"b2494df3","getReceivingConfig()":"287bc057","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","linkRemoteApp(uint256,bytes32)":"51a30802","linkRemoteAppEVM(uint256,address)":"af8fcc8e","removeInterchainClient(address)":"0fb59156","removeTrustedModule(address)":"b70c40b3","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","setAppConfigV1((uint256,uint256))":"0d32b505","setExecutionService(address)":"496774b1","setLatestInterchainClient(address)":"eb53b44e","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:IERC165":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.","kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.\",\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IERC165\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:IInterchainApp":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."}},"notice":"Minimal interface for the Interchain App to work with the Interchain Client.","version":1},"developerDoc":{"kind":"dev","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"}},\"notice\":\"Minimal interface for the Interchain App to work with the Interchain Client.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IInterchainApp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getReceivingConfig()":"287bc057"}},"solidity/ExampleAppV1.sol:IInterchainAppV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InterchainApp__AppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"InterchainApp__InvalidAppConfig","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__NotEVMLinkedApp","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"appConfig","type":"tuple"}],"name":"setAppConfigV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"addInterchainClient(address,bool)":{"notice":"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app."},"addTrustedModule(address)":{"notice":"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages."},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getAppConfigV1()":{"notice":"Returns the app config for the current app: requiredResponses and optimisticPeriod."},"getExecutionService()":{"notice":"Returns the address of the Execution Service used by this app for sending messages."},"getInterchainClients()":{"notice":"Returns the list of Interchain Clients allowed to send messages to this app."},"getLatestInterchainClient()":{"notice":"Returns the address of the latest interchain client. This address is used for sending messages from this app."},"getLinkedApp(uint256)":{"notice":"Returns the linked app address (as bytes32) for the given chain ID."},"getLinkedAppEVM(uint256)":{"notice":"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address."},"getModules()":{"notice":"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."},"linkRemoteApp(uint256,bytes32)":{"notice":"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain."},"linkRemoteAppEVM(uint256,address)":{"notice":"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter."},"removeInterchainClient(address)":{"notice":"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address."},"removeTrustedModule(address)":{"notice":"Allows the owner to remove the module from the trusted modules set."},"setAppConfigV1((uint256,uint256))":{"notice":"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final"},"setExecutionService(address)":{"notice":"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee."},"setLatestInterchainClient(address)":{"notice":"Allows the owner to set the address of the latest interchain client."}},"version":1},"developerDoc":{"kind":"dev","methods":{"addInterchainClient(address,bool)":{"params":{"client":"The address of the interchain client to add.","updateLatest":"Whether to set the latest client to this one."}},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getLinkedAppEVM(uint256)":{"details":"Will revert if the linked app address is not an EVM address."},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}},"linkRemoteApp(uint256,bytes32)":{"params":{"chainId":"The remote chain ID.","remoteApp":"The address of the remote app to link."}},"removeInterchainClient(address)":{"params":{"client":"The address of the interchain client to remove."}},"setLatestInterchainClient(address)":{"details":"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.","params":{"client":"The address of the latest interchain client."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InterchainApp__AppZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__InvalidAppConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__ModuleZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"linkedApp\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__NotEVMLinkedApp\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"updateLatest\",\"type\":\"bool\"}],\"name\":\"addInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"addTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAppConfigV1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExecutionService\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInterchainClients\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestInterchainClient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedApp\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedAppEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"linkRemoteApp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"remoteApp\",\"type\":\"address\"}],\"name\":\"linkRemoteAppEVM\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"removeInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"removeTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"appConfig\",\"type\":\"tuple\"}],\"name\":\"setAppConfigV1\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"setExecutionService\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"setLatestInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addInterchainClient(address,bool)\":{\"params\":{\"client\":\"The address of the interchain client to add.\",\"updateLatest\":\"Whether to set the latest client to this one.\"}},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getLinkedAppEVM(uint256)\":{\"details\":\"Will revert if the linked app address is not an EVM address.\"},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}},\"linkRemoteApp(uint256,bytes32)\":{\"params\":{\"chainId\":\"The remote chain ID.\",\"remoteApp\":\"The address of the remote app to link.\"}},\"removeInterchainClient(address)\":{\"params\":{\"client\":\"The address of the interchain client to remove.\"}},\"setLatestInterchainClient(address)\":{\"details\":\"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.\",\"params\":{\"client\":\"The address of the latest interchain client.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addInterchainClient(address,bool)\":{\"notice\":\"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app.\"},\"addTrustedModule(address)\":{\"notice\":\"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages.\"},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getAppConfigV1()\":{\"notice\":\"Returns the app config for the current app: requiredResponses and optimisticPeriod.\"},\"getExecutionService()\":{\"notice\":\"Returns the address of the Execution Service used by this app for sending messages.\"},\"getInterchainClients()\":{\"notice\":\"Returns the list of Interchain Clients allowed to send messages to this app.\"},\"getLatestInterchainClient()\":{\"notice\":\"Returns the address of the latest interchain client. This address is used for sending messages from this app.\"},\"getLinkedApp(uint256)\":{\"notice\":\"Returns the linked app address (as bytes32) for the given chain ID.\"},\"getLinkedAppEVM(uint256)\":{\"notice\":\"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\"},\"getModules()\":{\"notice\":\"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"},\"linkRemoteApp(uint256,bytes32)\":{\"notice\":\"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain.\"},\"linkRemoteAppEVM(uint256,address)\":{\"notice\":\"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\"},\"removeInterchainClient(address)\":{\"notice\":\"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address.\"},\"removeTrustedModule(address)\":{\"notice\":\"Allows the owner to remove the module from the trusted modules set.\"},\"setAppConfigV1((uint256,uint256))\":{\"notice\":\"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final\"},\"setExecutionService(address)\":{\"notice\":\"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee.\"},\"setLatestInterchainClient(address)\":{\"notice\":\"Allows the owner to set the address of the latest interchain client.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IInterchainAppV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"addInterchainClient(address,bool)":"f22ba23d","addTrustedModule(address)":"cb5038fb","appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getAppConfigV1()":"7717a647","getExecutionService()":"c313c807","getInterchainClients()":"a1aa5d68","getLatestInterchainClient()":"bc0d912c","getLinkedApp(uint256)":"b9b74b18","getLinkedAppEVM(uint256)":"a9ac04b6","getModules()":"b2494df3","getReceivingConfig()":"287bc057","linkRemoteApp(uint256,bytes32)":"51a30802","linkRemoteAppEVM(uint256,address)":"af8fcc8e","removeInterchainClient(address)":"0fb59156","removeTrustedModule(address)":"b70c40b3","setAppConfigV1((uint256,uint256))":"0d32b505","setExecutionService(address)":"496774b1","setLatestInterchainClient(address)":"eb53b44e"}},"solidity/ExampleAppV1.sol:IInterchainClientV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__FeeAmountTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__IncorrectDstChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__IncorrectMsgValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NoLinkedClient","type":"error"},{"inputs":[{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"InterchainClientV1__NotEVMClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__NotEnoughResponses","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NotRemoteChainId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxAlreadyExecuted","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxNotExecuted","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroReceiver","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroRequiredResponses","type":"error"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"}],"name":"getExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getExecutorById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"uint256","name":"messageLen","type":"uint256"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClient","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClientEVM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"interchainExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSend","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSendEVM","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"isExecutable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"executionFees_","type":"address"}],"name":"setExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"setLinkedClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"writeExecutionProof","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"getExecutor(bytes)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getExecutorById(bytes32)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getInterchainFee(uint256,address,address[],bytes,uint256)":{"notice":"Returns the fee for sending an Interchain message."},"getLinkedClient(uint256)":{"notice":"Returns the address of the linked client (as bytes32) for a specific chain ID."},"getLinkedClientEVM(uint256)":{"notice":"Returns the EVM address of the linked client for a specific chain ID."},"interchainExecute(uint256,bytes,bytes32[])":{"notice":"Executes a transaction that has been sent via the Interchain."},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"notice":"Sends a message to another chain via the Interchain Communication Protocol."},"isExecutable(bytes,bytes32[])":{"notice":"Checks if a transaction is executable."},"setExecutionFees(address)":{"notice":"Sets the address of the ExecutionFees contract."},"setLinkedClient(uint256,bytes32)":{"notice":"Sets the linked client for a specific chain ID."},"writeExecutionProof(bytes32)":{"notice":"Writes the proof of execution for a transaction into the InterchainDB."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getInterchainFee(uint256,address,address[],bytes,uint256)":{"params":{"dstChainId":"The chain ID of the destination chain.","messageLen":"The length of the message being sent.","options":"Execution options for the message sent, currently gas limit + native gas drop.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."}},"getLinkedClient(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID."},"getLinkedClientEVM(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client."},"interchainExecute(uint256,bytes,bytes32[])":{"details":"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.","params":{"gasLimit":"The gas limit to use for the execution.","proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The transaction data."}},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"details":"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.","params":{"dstChainId":"The chain ID of the destination chain.","message":"The message being sent.","options":"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.","receiver":"The address of the receiver on the destination chain.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."},"returns":{"desc":"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch."}},"isExecutable(bytes,bytes32[])":{"details":"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules","params":{"proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The InterchainTransaction struct to be checked."},"returns":{"_0":"bool Returns true if the transaction is executable, false otherwise."}},"setExecutionFees(address)":{"details":"Only callable by the contract owner or an authorized account.","params":{"executionFees_":"The address of the ExecutionFees contract."}},"setLinkedClient(uint256,bytes32)":{"details":"Stores the address of the linked client in a mapping with the chain ID as the key.","params":{"chainId":"The chain ID for which the client is being set.","client":"The address of the client being linked."}},"writeExecutionProof(bytes32)":{"details":"Will revert if the transaction has not been executed.","params":{"transactionId":"The ID of the transaction to write the proof for."},"returns":{"dbNonce":" The database nonce of the batch containing the written proof for transaction.","entryIndex":" The index of the written proof for transaction within the batch."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"messageLen\":\"The length of the message being sent.\",\"options\":\"Execution options for the message sent, currently gas limit + native gas drop.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"}},\"getLinkedClient(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"details\":\"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.\",\"params\":{\"gasLimit\":\"The gas limit to use for the execution.\",\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The transaction data.\"}},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"details\":\"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.\",\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"message\":\"The message being sent.\",\"options\":\"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\",\"receiver\":\"The address of the receiver on the destination chain.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"},\"returns\":{\"desc\":\"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch.\"}},\"isExecutable(bytes,bytes32[])\":{\"details\":\"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules\",\"params\":{\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The InterchainTransaction struct to be checked.\"},\"returns\":{\"_0\":\"bool Returns true if the transaction is executable, false otherwise.\"}},\"setExecutionFees(address)\":{\"details\":\"Only callable by the contract owner or an authorized account.\",\"params\":{\"executionFees_\":\"The address of the ExecutionFees contract.\"}},\"setLinkedClient(uint256,bytes32)\":{\"details\":\"Stores the address of the linked client in a mapping with the chain ID as the key.\",\"params\":{\"chainId\":\"The chain ID for which the client is being set.\",\"client\":\"The address of the client being linked.\"}},\"writeExecutionProof(bytes32)\":{\"details\":\"Will revert if the transaction has not been executed.\",\"params\":{\"transactionId\":\"The ID of the transaction to write the proof for.\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written proof for transaction.\",\"entryIndex\":\" The index of the written proof for transaction within the batch.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getExecutor(bytes)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getExecutorById(bytes32)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"notice\":\"Returns the fee for sending an Interchain message.\"},\"getLinkedClient(uint256)\":{\"notice\":\"Returns the address of the linked client (as bytes32) for a specific chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"notice\":\"Returns the EVM address of the linked client for a specific chain ID.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"notice\":\"Executes a transaction that has been sent via the Interchain.\"},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"notice\":\"Sends a message to another chain via the Interchain Communication Protocol.\"},\"isExecutable(bytes,bytes32[])\":{\"notice\":\"Checks if a transaction is executable.\"},\"setExecutionFees(address)\":{\"notice\":\"Sets the address of the ExecutionFees contract.\"},\"setLinkedClient(uint256,bytes32)\":{\"notice\":\"Sets the linked client for a specific chain ID.\"},\"writeExecutionProof(bytes32)\":{\"notice\":\"Writes the proof of execution for a transaction into the InterchainDB.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IInterchainClientV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{"getExecutor(bytes)":"f92a79ff","getExecutorById(bytes32)":"f1a61fac","getInterchainFee(uint256,address,address[],bytes,uint256)":"7a1277db","getLinkedClient(uint256)":"aa102ec4","getLinkedClientEVM(uint256)":"02172a35","interchainExecute(uint256,bytes,bytes32[])":"53b67d74","interchainSend(uint256,bytes32,address,address[],bytes,bytes)":"98939d28","interchainSendEVM(uint256,address,address,address[],bytes,bytes)":"827f940d","isExecutable(bytes,bytes32[])":"1450c281","setExecutionFees(address)":"3dc68b87","setLinkedClient(uint256,bytes32)":"f34234c8","writeExecutionProof(bytes32)":"90e81077"}},"solidity/ExampleAppV1.sol:InterchainAppV1Events":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"AppConfigV1Set\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"AppLinked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"ExecutionServiceSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleRemoved\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"InterchainAppV1Events\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:InterchainTransactionLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203b59d7a47fc00d5e1c1ab9bd21c738f0c2793102645062a014bae88c82b5faab64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212203b59d7a47fc00d5e1c1ab9bd21c738f0c2793102645062a014bae88c82b5faab64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"39920:1773:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;39920:1773:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"39920:1773:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"InterchainTransactionLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:MathLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b80747f8b8557b57a660253e634169764fff20fd7ee781fdc40e26936688207964736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b80747f8b8557b57a660253e634169764fff20fd7ee781fdc40e26936688207964736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"4708:403:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;4708:403:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"4708:403:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"MathLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212205820c4692021c760667fde1e3a50aa3286939777631d2b04cd8c72dc5105879664736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212205820c4692021c760667fde1e3a50aa3286939777631d2b04cd8c72dc5105879664736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"5630:1958:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;5630:1958:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"5630:1958:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:TypeCasts":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204d640c45c6f44a8c6c3918b01efb07db9ef2045645900d94931f2cb81901643664736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204d640c45c6f44a8c6c3918b01efb07db9ef2045645900d94931f2cb81901643664736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n uint8 constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned app config into a bytes format.\n /// @param version The version of the app config.\n /// @param appConfig The app config to encode.\n function encodeVersionedAppConfig(uint8 version, bytes memory appConfig) internal pure returns (bytes memory) {\n return abi.encode(version, appConfig);\n }\n\n /// @notice Decodes versioned app config from a bytes format back into a version and app config.\n /// @param data The versioned app config data in bytes format.\n /// @return version The version of the app config.\n /// @return appConfig The app config as bytes.\n function decodeVersionedAppConfig(bytes memory data)\n internal\n pure\n returns (uint8 version, bytes memory appConfig)\n {\n (version, appConfig) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return encodeVersionedAppConfig(APP_CONFIG_V1, abi.encode(appConfig));\n }\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal pure returns (AppConfigV1 memory) {\n (uint8 version, bytes memory appConfig) = decodeVersionedAppConfig(data);\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(appConfig, (AppConfigV1));\n }\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"7623:280:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;7623:280:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"7623:280:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"TypeCasts\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x07e7053d3cce3c7d0d3c596f55e14bdabb076f106d827f067f7eb511e9249f4e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b2060e4650ea8debdaf1d94d0b75bdc6920ea437e042a9f944f73afa1463f400\",\"dweb:/ipfs/QmcvzyJyTgVXqky8PTsFeWoiyBp6aTamEHyyGdLqRM9JEv\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file +{"solidity/ExampleAppV1.sol:AbstractICApp":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__AlreadyLatestClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainApp__BalanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__ClientAlreadyAdded","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__ReceiverNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__SameChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."}},"version":1},"developerDoc":{"kind":"dev","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__AlreadyLatestClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__BalanceTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__ClientAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__InterchainClientZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"InterchainApp__NotInterchainClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__ReceiverNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__SenderNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AbstractICApp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getReceivingConfig()":"287bc057"}},"solidity/ExampleAppV1.sol:AbstractICAppEvents":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AbstractICAppEvents\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:AccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module that allows children to implement role-based access control mechanisms. This is a lightweight version that doesn't allow enumerating role members except through off-chain means by accessing the contract event logs. Some applications may benefit from on-chain enumerability, for those cases see {AccessControlEnumerable}. Roles are referred to by their `bytes32` identifier. These should be exposed in the external API and be unique. The best way to achieve this is by using `public constant` hash digests: ```solidity bytes32 public constant MY_ROLE = keccak256(\\\"MY_ROLE\\\"); ``` Roles can be used to represent a set of permissions. To restrict access to a function call, use {hasRole}: ```solidity function foo() public { require(hasRole(MY_ROLE, msg.sender)); ... } ``` Roles can be granted and revoked dynamically via the {grantRole} and {revokeRole} functions. Each role has an associated admin role, and only accounts that have a role's admin role can call {grantRole} and {revokeRole}. By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means that only accounts with this role will be able to grant or revoke other roles. More complex role relationships can be created by using {_setRoleAdmin}. WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to grant and revoke this role. Extra precautions should be taken to secure accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} to enforce additional security measures for this role.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:AccessControlEnumerable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Extension of {AccessControl} that allows enumerating the members of each role.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Extension of {AccessControl} that allows enumerating the members of each role.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AccessControlEnumerable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:Address":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207fab21237433ebd54f1a50678d230e2a4e3457ad1c0aa0fe910a126bb3726c9e64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207fab21237433ebd54f1a50678d230e2a4e3457ad1c0aa0fe910a126bb3726c9e64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"10522:6066:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;10522:6066:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"10522:6066:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Collection of functions related to the address type","errors":{"AddressEmptyCode(address)":[{"details":"There's no code at `target` (it is not a contract)."}],"AddressInsufficientBalance(address)":[{"details":"The ETH balance of the account is not enough to perform the operation."}],"FailedInnerCall()":[{"details":"A call to an address target failed. The target may have reverted."}]},"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"}],\"devdoc\":{\"details\":\"Collection of functions related to the address type\",\"errors\":{\"AddressEmptyCode(address)\":[{\"details\":\"There's no code at `target` (it is not a contract).\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}]},\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"Address\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:AppConfigLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b54fc094ca85e678bfd68635c4ef2fc11e9a229a43ece4f62eca9f4f9060a8f964736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220b54fc094ca85e678bfd68635c4ef2fc11e9a229a43ece4f62eca9f4f9060a8f964736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"31589:1275:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;31589:1275:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"31589:1275:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"AppConfigLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"AppConfigLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"AppConfigLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:Context":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"Context\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:ERC165":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```","kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Implementation of the {IERC165} interface. Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check for the additional interface id that will be supported. For example: ```solidity function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); } ```\",\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"ERC165\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:EnumerableSet":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201ae3b573fa1c4e3c2c3277a6cd4c5e4c56e00e88c23a03bb6859c810cd636ce664736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212201ae3b573fa1c4e3c2c3277a6cd4c5e4c56e00e88c23a03bb6859c810cd636ce664736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"19785:11640:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;19785:11640:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"19785:11640:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time (O(1)). - Elements are enumerated in O(n). No guarantees are made on the ordering. ```solidity contract Example { // Add the library methods using EnumerableSet for EnumerableSet.AddressSet; // Declare a set state variable EnumerableSet.AddressSet private mySet; } ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) and `uint256` (`UintSet`) are supported. [WARNING] ==== Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. ====","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Library for managing https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive types. Sets have the following properties: - Elements are added, removed, and checked for existence in constant time (O(1)). - Elements are enumerated in O(n). No guarantees are made on the ordering. ```solidity contract Example { // Add the library methods using EnumerableSet for EnumerableSet.AddressSet; // Declare a set state variable EnumerableSet.AddressSet private mySet; } ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) and `uint256` (`UintSet`) are supported. [WARNING] ==== Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. ====\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"EnumerableSet\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:ExampleAppV1":{"code":"0x60806040523480156200001157600080fd5b50604051620024f0380380620024f08339810160408190526200003491620001be565b806200004260008262000079565b506200007190507f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c848262000079565b5050620001e9565b600080620000888484620000b6565b90508015620000ad576000848152600160205260409020620000ab908462000164565b505b90505b92915050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166200015b576000838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055620001123390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620000b0565b506000620000b0565b6000620000ad836001600160a01b03841660008181526001830160205260408120546200015b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620000b0565b600060208284031215620001d157600080fd5b81516001600160a01b0381168114620000ad57600080fd5b6122f780620001f96000396000f3fe6080604052600436106101d85760003560e01c80639010d07c11610102578063b9b74b1811610095578063cb5038fb11610064578063cb5038fb146105b7578063d547741f146105d7578063eb53b44e146105f7578063f22ba23d1461061757600080fd5b8063b9b74b181461052e578063bc0d912c1461055b578063c313c80714610579578063ca15c8731461059757600080fd5b8063a9ac04b6116100d1578063a9ac04b6146104b9578063af8fcc8e146104d9578063b2494df3146104f9578063b70c40b31461050e57600080fd5b80639010d07c1461040657806391d148541461043e578063a1aa5d6814610482578063a217fddf146104a457600080fd5b80632f2ff15d1161017a57806351a308021161014957806351a308021461037157806368a6984714610391578063764ca1e8146103a45780637717a647146103c457600080fd5b80632f2ff15d146102fc57806336568abe1461031c5780633ccfd60b1461033c578063496774b11461035157600080fd5b80631c489e4f116101b65780631c489e4f14610254578063248a9ca314610296578063282be0e9146102c6578063287bc057146102d957600080fd5b806301ffc9a7146101dd5780630d32b505146102125780630fb5915614610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b55565b610637565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004611c15565b610693565b005b34801561024057600080fd5b5061023261024f366004611c80565b610766565b34801561026057600080fd5b506102887f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8481565b604051908152602001610209565b3480156102a257600080fd5b506102886102b1366004611c9b565b60009081526020819052604090206001015490565b6102326102d4366004611cfd565b61079d565b3480156102e557600080fd5b506102ee61085b565b604051610209929190611e10565b34801561030857600080fd5b50610232610317366004611e35565b610876565b34801561032857600080fd5b50610232610337366004611e35565b6108a1565b34801561034857600080fd5b506102326108f2565b34801561035d57600080fd5b5061023261036c366004611c80565b61090a565b34801561037d57600080fd5b5061023261038c366004611e61565b61099a565b61023261039f366004611e99565b6109ce565b3480156103b057600080fd5b506102886103bf366004611f0c565b610ab2565b3480156103d057600080fd5b50604080518082018252600080825260209182015281518083019092526003548252600454908201526040516102099190611fdc565b34801561041257600080fd5b50610426610421366004611e61565b610add565b6040516001600160a01b039091168152602001610209565b34801561044a57600080fd5b506101fd610459366004611e35565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561048e57600080fd5b50610497610afc565b6040516102099190611ff3565b3480156104b057600080fd5b50610288600081565b3480156104c557600080fd5b506104266104d4366004611c9b565b610b0d565b3480156104e557600080fd5b506102326104f4366004611e35565b610b68565b34801561050557600080fd5b50610497610ba5565b34801561051a57600080fd5b50610232610529366004611c80565b610bb1565b34801561053a57600080fd5b50610288610549366004611c9b565b60009081526005602052604090205490565b34801561056757600080fd5b506002546001600160a01b0316610426565b34801561058557600080fd5b50600a546001600160a01b0316610426565b3480156105a357600080fd5b506102886105b2366004611c9b565b610c6e565b3480156105c357600080fd5b506102326105d2366004611c80565b610c85565b3480156105e357600080fd5b506102326105f2366004611e35565b610d79565b34801561060357600080fd5b50610232610612366004611c80565b610d9e565b34801561062357600080fd5b50610232610632366004612006565b610dd1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061068d575061068d82610e05565b92915050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846106bd81610e9c565b815115806106cd57506020820151155b1561071957815160208301516040517f8bdc31dd000000000000000000000000000000000000000000000000000000008152600481019290925260248201526044015b60405180910390fd5b81516003819055602080840151600481905560408051938452918301527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a15050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461079081610e9c565b61079982610ea6565b5050565b60006107f5863460405180604001604052808981526020018881525086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f6592505050565b602080820151604080840151845182518c81529485019390935267ffffffffffffffff169083015260608201529091507f2ef16db2691a32543ce5591798c4992f4cfbbcd446874f1437d99da53d600e7c906080015b60405180910390a1505050505050565b606080610866610fb5565b9150610870610ba5565b90509091565b60008281526020819052604090206001015461089181610e9c565b61089b8383610fd8565b50505050565b6001600160a01b03811633146108e3576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108ed828261100d565b505050565b60006108fd81610e9c565b610907334761103a565b50565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461093481610e9c565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e9060200161075a565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846109c481610e9c565b6108ed8383611103565b6109d7336111b9565b610a0f576040517f0578f695000000000000000000000000000000000000000000000000000000008152336004820152602401610710565b468603610a4b576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101879052602401610710565b6000868152600560205260409020548514610a9c576040517f327f41230000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604401610710565b610aaa8686868686866111c6565b505050505050565b6000610ad48560405180604001604052808781526020018681525084516111ff565b95945050505050565b6000828152600160205260408120610af59083611218565b9392505050565b6060610b086006611224565b905090565b600081815260056020526040902054806001600160a01b0381168114610b62576040517ff04c4a4500000000000000000000000000000000000000000000000000000000815260048101829052602401610710565b50919050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610b9281610e9c565b6108ed836001600160a01b038416611103565b6060610b086008611224565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610bdb81610e9c565b6000610be8600884611231565b905080610c2c576040517fb12a48e60000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a1505050565b600081815260016020526040812061068d90611246565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610caf81610e9c565b6001600160a01b038216610cef576040517fa8ce0c2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610cfc600884611250565b905080610d40576040517f856e38ac0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610c61565b600082815260208190526040902060010154610d9481610e9c565b61089b838361100d565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dc881610e9c565b61079982611265565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dfb81610e9c565b6108ed8383611398565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461068d565b6109078133611479565b610eaf816111b9565b610ef0576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b610efb8160006114e5565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b031603610907576109076000611265565b6040805160608101825260008082526020820181905291810182905290610f8b84611501565b600087815260056020526040902054909150610fab90879087848761152d565b9695505050505050565b6040805180820190915260035481526004546020820152606090610b0890611501565b600080610fe584846116fa565b90508015610af55760008481526001602052604090206110059084611250565b509392505050565b60008061101a84846117c2565b90508015610af55760008481526001602052604090206110059084611231565b80471015611076576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610710565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110c3576040519150601f19603f3d011682016040523d82523d6000602084013e6110c8565b606091505b50509050806108ed576040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46820361113f576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101839052602401610710565b600081900361117a576040517fe04fb69600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526005602052604080822083905551829184917f622d488f4fb24881af2fe5b552b249253a21e4a6fa77d12e69f61ee0fdfb9a319190a35050565b600061068d600683611863565b7fc5b07cf0d424748241636d3a67366b44ac88118c42bef024abcb7fd138df79a686868686868660405161084b96959493929190612042565b60008061120b84611501565b9050610ad4858285611885565b6000610af58383611969565b60606000610af583611993565b6000610af5836001600160a01b0384166119ef565b600061068d825490565b6000610af5836001600160a01b038416611ae2565b61126e816111b9565b15801561128357506001600160a01b03811615155b156112c5576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b6002546001600160a01b03166001600160a01b0316816001600160a01b031603611326576040517f56c309440000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c1699060200160405180910390a150565b6001600160a01b0382166113d8576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e1826111b9565b15611423576040517f4ea647680000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610710565b61142e8260016114e5565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156107995761079982611265565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610799576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610710565b80156114f6576108ed600683611250565b6108ed600683611231565b606061068d6001836040516020016115199190611fdc565b604051602081830303815290604052611b29565b6040805160608101825260008082526020820181905291810191909152600061155e6002546001600160a01b031690565b90506001600160a01b0381166115a0576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4687036115dc576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b600086900361161a576040517f9a3e6bd400000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b8447101561165d576040517f5b59cdf200000000000000000000000000000000000000000000000000000000815247600482015260248101869052604401610710565b806001600160a01b03166398939d28868989611681600a546001600160a01b031690565b611689610ba5565b8a8a6040518863ffffffff1660e01b81526004016116ac969594939291906120b5565b60606040518083038185885af11580156116ca573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116ef9190612116565b979650505050505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166117ba576000838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556117723390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161068d565b50600061068d565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16156117ba576000838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161068d565b6001600160a01b03811660009081526001830160205260408120541515610af5565b60008061189a6002546001600160a01b031690565b90506001600160a01b0381166118dc576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806001600160a01b0316637a1277db866118fe600a546001600160a01b031690565b611906610ba5565b88886040518663ffffffff1660e01b8152600401611928959493929190612178565b602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad491906121c5565b6000826000018281548110611980576119806121de565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156119e357602002820191906000526020600020905b8154815260200190600101908083116119cf575b50505050509050919050565b60008181526001830160205260408120548015611ad8576000611a1360018361220d565b8554909150600090611a279060019061220d565b9050808214611a8c576000866000018281548110611a4757611a476121de565b9060005260206000200154905080876000018481548110611a6a57611a6a6121de565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a9d57611a9d612247565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061068d565b600091505061068d565b60008181526001830160205260408120546117ba5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561068d565b60608282604051602001611b3e929190612276565b604051602081830303815290604052905092915050565b600060208284031215611b6757600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610af557600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c0d57611c0d611b97565b604052919050565b600060408284031215611c2757600080fd5b6040516040810181811067ffffffffffffffff82111715611c4a57611c4a611b97565b604052823581526020928301359281019290925250919050565b80356001600160a01b0381168114611c7b57600080fd5b919050565b600060208284031215611c9257600080fd5b610af582611c64565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b50813567ffffffffffffffff811115611cde57600080fd5b602083019150836020828501011115611cf657600080fd5b9250929050565b600080600080600060808688031215611d1557600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff811115611d4157600080fd5b611d4d88828901611cb4565b969995985093965092949392505050565b60005b83811015611d79578181015183820152602001611d61565b50506000910152565b60008151808452611d9a816020860160208601611d5e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600081518084526020808501945080840160005b83811015611e055781516001600160a01b031687529582019590820190600101611de0565b509495945050505050565b604081526000611e236040830185611d82565b8281036020840152610ad48185611dcc565b60008060408385031215611e4857600080fd5b82359150611e5860208401611c64565b90509250929050565b60008060408385031215611e7457600080fd5b50508035926020909101359150565b67ffffffffffffffff8116811461090757600080fd5b60008060008060008060a08789031215611eb257600080fd5b8635955060208701359450604087013593506060870135611ed281611e83565b9250608087013567ffffffffffffffff811115611eee57600080fd5b611efa89828a01611cb4565b979a9699509497509295939492505050565b60008060008060808587031215611f2257600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff80821115611f5057600080fd5b818801915088601f830112611f6457600080fd5b813581811115611f7657611f76611b97565b611fa6847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611bc6565b91508082528984828501011115611fbc57600080fd5b808484018584013760008482840101525080935050505092959194509250565b81518152602080830151908201526040810161068d565b602081526000610af56020830184611dcc565b6000806040838503121561201957600080fd5b61202283611c64565b91506020830135801515811461203757600080fd5b809150509250929050565b86815285602082015284604082015267ffffffffffffffff8416606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b8681528560208201526001600160a01b038516604082015260c0606082015260006120e360c0830186611dcc565b82810360808401526120f58186611d82565b905082810360a08401526121098185611d82565b9998505050505050505050565b60006060828403121561212857600080fd5b6040516060810181811067ffffffffffffffff8211171561214b5761214b611b97565b80604052508251815260208301516020820152604083015161216c81611e83565b60408201529392505050565b8581526001600160a01b038516602082015260a0604082015260006121a060a0830186611dcc565b82810360608401526121b28186611d82565b9150508260808301529695505050505050565b6000602082840312156121d757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8181038181111561068d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b168152600082516122b3816002850160208701611d5e565b91909101600201939250505056fea2646970667358221220d14e9c75b1404f40a6358d9573f563fb2dee2ed56dc07a00419c29e57cef150b64736f6c63430008140033","runtime-code":"0x6080604052600436106101d85760003560e01c80639010d07c11610102578063b9b74b1811610095578063cb5038fb11610064578063cb5038fb146105b7578063d547741f146105d7578063eb53b44e146105f7578063f22ba23d1461061757600080fd5b8063b9b74b181461052e578063bc0d912c1461055b578063c313c80714610579578063ca15c8731461059757600080fd5b8063a9ac04b6116100d1578063a9ac04b6146104b9578063af8fcc8e146104d9578063b2494df3146104f9578063b70c40b31461050e57600080fd5b80639010d07c1461040657806391d148541461043e578063a1aa5d6814610482578063a217fddf146104a457600080fd5b80632f2ff15d1161017a57806351a308021161014957806351a308021461037157806368a6984714610391578063764ca1e8146103a45780637717a647146103c457600080fd5b80632f2ff15d146102fc57806336568abe1461031c5780633ccfd60b1461033c578063496774b11461035157600080fd5b80631c489e4f116101b65780631c489e4f14610254578063248a9ca314610296578063282be0e9146102c6578063287bc057146102d957600080fd5b806301ffc9a7146101dd5780630d32b505146102125780630fb5915614610234575b600080fd5b3480156101e957600080fd5b506101fd6101f8366004611b55565b610637565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061023261022d366004611c15565b610693565b005b34801561024057600080fd5b5061023261024f366004611c80565b610766565b34801561026057600080fd5b506102887f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8481565b604051908152602001610209565b3480156102a257600080fd5b506102886102b1366004611c9b565b60009081526020819052604090206001015490565b6102326102d4366004611cfd565b61079d565b3480156102e557600080fd5b506102ee61085b565b604051610209929190611e10565b34801561030857600080fd5b50610232610317366004611e35565b610876565b34801561032857600080fd5b50610232610337366004611e35565b6108a1565b34801561034857600080fd5b506102326108f2565b34801561035d57600080fd5b5061023261036c366004611c80565b61090a565b34801561037d57600080fd5b5061023261038c366004611e61565b61099a565b61023261039f366004611e99565b6109ce565b3480156103b057600080fd5b506102886103bf366004611f0c565b610ab2565b3480156103d057600080fd5b50604080518082018252600080825260209182015281518083019092526003548252600454908201526040516102099190611fdc565b34801561041257600080fd5b50610426610421366004611e61565b610add565b6040516001600160a01b039091168152602001610209565b34801561044a57600080fd5b506101fd610459366004611e35565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561048e57600080fd5b50610497610afc565b6040516102099190611ff3565b3480156104b057600080fd5b50610288600081565b3480156104c557600080fd5b506104266104d4366004611c9b565b610b0d565b3480156104e557600080fd5b506102326104f4366004611e35565b610b68565b34801561050557600080fd5b50610497610ba5565b34801561051a57600080fd5b50610232610529366004611c80565b610bb1565b34801561053a57600080fd5b50610288610549366004611c9b565b60009081526005602052604090205490565b34801561056757600080fd5b506002546001600160a01b0316610426565b34801561058557600080fd5b50600a546001600160a01b0316610426565b3480156105a357600080fd5b506102886105b2366004611c9b565b610c6e565b3480156105c357600080fd5b506102326105d2366004611c80565b610c85565b3480156105e357600080fd5b506102326105f2366004611e35565b610d79565b34801561060357600080fd5b50610232610612366004611c80565b610d9e565b34801561062357600080fd5b50610232610632366004612006565b610dd1565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f00000000000000000000000000000000000000000000000000000000148061068d575061068d82610e05565b92915050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846106bd81610e9c565b815115806106cd57506020820151155b1561071957815160208301516040517f8bdc31dd000000000000000000000000000000000000000000000000000000008152600481019290925260248201526044015b60405180910390fd5b81516003819055602080840151600481905560408051938452918301527f156e53f21add5e964d33e39e015675e24d4568202b47744bd8cc6080f76deabf91015b60405180910390a15050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461079081610e9c565b61079982610ea6565b5050565b60006107f5863460405180604001604052808981526020018881525086868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f6592505050565b602080820151604080840151845182518c81529485019390935267ffffffffffffffff169083015260608201529091507f2ef16db2691a32543ce5591798c4992f4cfbbcd446874f1437d99da53d600e7c906080015b60405180910390a1505050505050565b606080610866610fb5565b9150610870610ba5565b90509091565b60008281526020819052604090206001015461089181610e9c565b61089b8383610fd8565b50505050565b6001600160a01b03811633146108e3576040517f6697b23200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108ed828261100d565b505050565b60006108fd81610e9c565b610907334761103a565b50565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c8461093481610e9c565b600a80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527f56f2046f579030345e1c12cfd7e2d297e4059c24d30ac1a5cb27a8ee1d53526e9060200161075a565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c846109c481610e9c565b6108ed8383611103565b6109d7336111b9565b610a0f576040517f0578f695000000000000000000000000000000000000000000000000000000008152336004820152602401610710565b468603610a4b576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101879052602401610710565b6000868152600560205260409020548514610a9c576040517f327f41230000000000000000000000000000000000000000000000000000000081526004810187905260248101869052604401610710565b610aaa8686868686866111c6565b505050505050565b6000610ad48560405180604001604052808781526020018681525084516111ff565b95945050505050565b6000828152600160205260408120610af59083611218565b9392505050565b6060610b086006611224565b905090565b600081815260056020526040902054806001600160a01b0381168114610b62576040517ff04c4a4500000000000000000000000000000000000000000000000000000000815260048101829052602401610710565b50919050565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610b9281610e9c565b6108ed836001600160a01b038416611103565b6060610b086008611224565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610bdb81610e9c565b6000610be8600884611231565b905080610c2c576040517fb12a48e60000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f91071153b5721fdadecd5ab74cedca9c0faa62c94f02ef659df2241602698385906020015b60405180910390a1505050565b600081815260016020526040812061068d90611246565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610caf81610e9c565b6001600160a01b038216610cef576040517fa8ce0c2e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610cfc600884611250565b905080610d40576040517f856e38ac0000000000000000000000000000000000000000000000000000000081526001600160a01b0384166004820152602401610710565b6040516001600160a01b03841681527f0f92a0308a1fb283891a96a4cf077b8499cca0159d8e6ccc8d12096a5011750990602001610c61565b600082815260208190526040902060010154610d9481610e9c565b61089b838361100d565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dc881610e9c565b61079982611265565b7f67458b9c8206fd7556afadce1bc8e28c7a8942ecb92d9d9fad69bb6c8cf75c84610dfb81610e9c565b6108ed8383611398565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461068d565b6109078133611479565b610eaf816111b9565b610ef0576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b610efb8160006114e5565b6040516001600160a01b03821681527fc0d64f9e088893f1e4aea6d42c0e815f158ca62962029260f3c2b079d97feccc9060200160405180910390a16002546001600160a01b03166001600160a01b0316816001600160a01b031603610907576109076000611265565b6040805160608101825260008082526020820181905291810182905290610f8b84611501565b600087815260056020526040902054909150610fab90879087848761152d565b9695505050505050565b6040805180820190915260035481526004546020820152606090610b0890611501565b600080610fe584846116fa565b90508015610af55760008481526001602052604090206110059084611250565b509392505050565b60008061101a84846117c2565b90508015610af55760008481526001602052604090206110059084611231565b80471015611076576040517fcd786059000000000000000000000000000000000000000000000000000000008152306004820152602401610710565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146110c3576040519150601f19603f3d011682016040523d82523d6000602084013e6110c8565b606091505b50509050806108ed576040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b46820361113f576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101839052602401610710565b600081900361117a576040517fe04fb69600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008281526005602052604080822083905551829184917f622d488f4fb24881af2fe5b552b249253a21e4a6fa77d12e69f61ee0fdfb9a319190a35050565b600061068d600683611863565b7fc5b07cf0d424748241636d3a67366b44ac88118c42bef024abcb7fd138df79a686868686868660405161084b96959493929190612042565b60008061120b84611501565b9050610ad4858285611885565b6000610af58383611969565b60606000610af583611993565b6000610af5836001600160a01b0384166119ef565b600061068d825490565b6000610af5836001600160a01b038416611ae2565b61126e816111b9565b15801561128357506001600160a01b03811615155b156112c5576040517f0578f6950000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b6002546001600160a01b03166001600160a01b0316816001600160a01b031603611326576040517f56c309440000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610710565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556040516001600160a01b03821681527fd6c4ff3ce819d1fe47a30bb776376d847d8085a73ebf92dbf4058c36fdd5c1699060200160405180910390a150565b6001600160a01b0382166113d8576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e1826111b9565b15611423576040517f4ea647680000000000000000000000000000000000000000000000000000000081526001600160a01b0383166004820152602401610710565b61142e8260016114e5565b6040516001600160a01b03831681527f9963c5d146abd18838e0638ea82ec86b9a726e15fd852cab94aeebcd8bf438d19060200160405180910390a180156107995761079982611265565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610799576040517fe2517d3f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260248101839052604401610710565b80156114f6576108ed600683611250565b6108ed600683611231565b606061068d6001836040516020016115199190611fdc565b604051602081830303815290604052611b29565b6040805160608101825260008082526020820181905291810191909152600061155e6002546001600160a01b031690565b90506001600160a01b0381166115a0576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4687036115dc576040517fbfae2eb700000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b600086900361161a576040517f9a3e6bd400000000000000000000000000000000000000000000000000000000815260048101889052602401610710565b8447101561165d576040517f5b59cdf200000000000000000000000000000000000000000000000000000000815247600482015260248101869052604401610710565b806001600160a01b03166398939d28868989611681600a546001600160a01b031690565b611689610ba5565b8a8a6040518863ffffffff1660e01b81526004016116ac969594939291906120b5565b60606040518083038185885af11580156116ca573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906116ef9190612116565b979650505050505050565b6000828152602081815260408083206001600160a01b038516845290915281205460ff166117ba576000838152602081815260408083206001600160a01b0386168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556117723390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161068d565b50600061068d565b6000828152602081815260408083206001600160a01b038516845290915281205460ff16156117ba576000838152602081815260408083206001600160a01b038616808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161068d565b6001600160a01b03811660009081526001830160205260408120541515610af5565b60008061189a6002546001600160a01b031690565b90506001600160a01b0381166118dc576040517f6be4ac5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806001600160a01b0316637a1277db866118fe600a546001600160a01b031690565b611906610ba5565b88886040518663ffffffff1660e01b8152600401611928959493929190612178565b602060405180830381865afa158015611945573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad491906121c5565b6000826000018281548110611980576119806121de565b9060005260206000200154905092915050565b6060816000018054806020026020016040519081016040528092919081815260200182805480156119e357602002820191906000526020600020905b8154815260200190600101908083116119cf575b50505050509050919050565b60008181526001830160205260408120548015611ad8576000611a1360018361220d565b8554909150600090611a279060019061220d565b9050808214611a8c576000866000018281548110611a4757611a476121de565b9060005260206000200154905080876000018481548110611a6a57611a6a6121de565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611a9d57611a9d612247565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061068d565b600091505061068d565b60008181526001830160205260408120546117ba5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561068d565b60608282604051602001611b3e929190612276565b604051602081830303815290604052905092915050565b600060208284031215611b6757600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610af557600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611c0d57611c0d611b97565b604052919050565b600060408284031215611c2757600080fd5b6040516040810181811067ffffffffffffffff82111715611c4a57611c4a611b97565b604052823581526020928301359281019290925250919050565b80356001600160a01b0381168114611c7b57600080fd5b919050565b600060208284031215611c9257600080fd5b610af582611c64565b600060208284031215611cad57600080fd5b5035919050565b60008083601f840112611cc657600080fd5b50813567ffffffffffffffff811115611cde57600080fd5b602083019150836020828501011115611cf657600080fd5b9250929050565b600080600080600060808688031215611d1557600080fd5b853594506020860135935060408601359250606086013567ffffffffffffffff811115611d4157600080fd5b611d4d88828901611cb4565b969995985093965092949392505050565b60005b83811015611d79578181015183820152602001611d61565b50506000910152565b60008151808452611d9a816020860160208601611d5e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600081518084526020808501945080840160005b83811015611e055781516001600160a01b031687529582019590820190600101611de0565b509495945050505050565b604081526000611e236040830185611d82565b8281036020840152610ad48185611dcc565b60008060408385031215611e4857600080fd5b82359150611e5860208401611c64565b90509250929050565b60008060408385031215611e7457600080fd5b50508035926020909101359150565b67ffffffffffffffff8116811461090757600080fd5b60008060008060008060a08789031215611eb257600080fd5b8635955060208701359450604087013593506060870135611ed281611e83565b9250608087013567ffffffffffffffff811115611eee57600080fd5b611efa89828a01611cb4565b979a9699509497509295939492505050565b60008060008060808587031215611f2257600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff80821115611f5057600080fd5b818801915088601f830112611f6457600080fd5b813581811115611f7657611f76611b97565b611fa6847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611bc6565b91508082528984828501011115611fbc57600080fd5b808484018584013760008482840101525080935050505092959194509250565b81518152602080830151908201526040810161068d565b602081526000610af56020830184611dcc565b6000806040838503121561201957600080fd5b61202283611c64565b91506020830135801515811461203757600080fd5b809150509250929050565b86815285602082015284604082015267ffffffffffffffff8416606082015260a060808201528160a0820152818360c0830137600081830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b8681528560208201526001600160a01b038516604082015260c0606082015260006120e360c0830186611dcc565b82810360808401526120f58186611d82565b905082810360a08401526121098185611d82565b9998505050505050505050565b60006060828403121561212857600080fd5b6040516060810181811067ffffffffffffffff8211171561214b5761214b611b97565b80604052508251815260208301516020820152604083015161216c81611e83565b60408201529392505050565b8581526001600160a01b038516602082015260a0604082015260006121a060a0830186611dcc565b82810360608401526121b28186611d82565b9150508260808301529695505050505050565b6000602082840312156121d757600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b8181038181111561068d577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b168152600082516122b3816002850160208701611d5e565b91909101600201939250505056fea2646970667358221220d14e9c75b1404f40a6358d9573f563fb2dee2ed56dc07a00419c29e57cef150b64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"79861:1995:0:-:0;;;80117:94;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;80152:5;70929:37;53479:4;80152:5;70929:10;:37::i;:::-;-1:-1:-1;80169:35:0::1;::::0;-1:-1:-1;70160:29:0::1;80198:5:::0;80169:10:::1;:35::i;:::-;;80117:94:::0;79861:1995;;69160:257;69246:4;;69277:31;69294:4;69300:7;69277:16;:31::i;:::-;69262:46;;69322:7;69318:69;;;69345:18;;;;:12;:18;;;;;:31;;69368:7;69345:22;:31::i;:::-;;69318:69;69403:7;-1:-1:-1;69160:257:0;;;;;:::o;57426:316::-;57503:4;54201:12;;;;;;;;;;;-1:-1:-1;;;;;54201:29:0;;;;;;;;;;;;57519:217;;57562:6;:12;;;;;;;;;;;-1:-1:-1;;;;;57562:29:0;;;;;;;;;:36;;-1:-1:-1;;57562:36:0;57594:4;57562:36;;;57644:12;17326:10;;17247:96;57644:12;-1:-1:-1;;;;;57617:40:0;57635:7;-1:-1:-1;;;;;57617:40:0;57629:4;57617:40;;;;;;;;;;-1:-1:-1;57678:4:0;57671:11;;57519:217;-1:-1:-1;57720:5:0;57713:12;;26771:150;26841:4;26864:50;26869:3;-1:-1:-1;;;;;26889:23:0;;20759:4;22815:21;;;:14;;;:21;;;;;;20775:321;;-1:-1:-1;20817:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;20999:18;;20975:21;;;:14;;;:21;;;;;;:42;;;;21031:11;;14:290:1;84:6;137:2;125:9;116:7;112:23;108:32;105:52;;;153:1;150;143:12;105:52;179:16;;-1:-1:-1;;;;;224:31:1;;214:42;;204:70;;270:1;267;260:12;14:290;79861:1995:0;;;;;;","srcMapRuntime":"79861:1995:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;67820:212;;;;;;;;;;-1:-1:-1;67820:212:0;;;;;:::i;:::-;;:::i;:::-;;;516:14:1;;509:22;491:41;;479:2;464:18;67820:212:0;;;;;;;;72679:419;;;;;;;;;;-1:-1:-1;72679:419:0;;;;;:::i;:::-;;:::i;:::-;;71208:122;;;;;;;;;;-1:-1:-1;71208:122:0;;;;;:::i;:::-;;:::i;70117:72::-;;;;;;;;;;;;70160:29;70117:72;;;;;2122:25:1;;;2110:2;2095:18;70117:72:0;1976:177:1;55057:120:0;;;;;;;;;;-1:-1:-1;55057:120:0;;;;;:::i;:::-;55122:7;55148:12;;;;;;;;;;:22;;;;55057:120;80504:528;;;;;;:::i;:::-;;:::i;59684:180::-;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;55473:136::-;;;;;;;;;;-1:-1:-1;55473:136:0;;;;;:::i;:::-;;:::i;56575:245::-;;;;;;;;;;-1:-1:-1;56575:245:0;;;;;:::i;:::-;;:::i;80298:136::-;;;;;;;;;;;;;:::i;73141:196::-;;;;;;;;;;-1:-1:-1;73141:196:0;;;;;:::i;:::-;;:::i;71544:146::-;;;;;;;;;;-1:-1:-1;71544:146:0;;;;;:::i;:::-;;:::i;58990:653::-;;;;;;:::i;:::-;;:::i;81118:324::-;;;;;;;;;;-1:-1:-1;81118:324:0;;;;;:::i;:::-;;:::i;73714:105::-;;;;;;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;73793:19:0;;;;;;;;73800:12;73793:19;;;;;;;;;73714:105;;;;;;:::i;68617:142::-;;;;;;;;;;-1:-1:-1;68617:142:0;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;8268:55:1;;;8250:74;;8238:2;8223:18;68617:142:0;8104:226:1;54101:136:0;;;;;;;;;;-1:-1:-1;54101:136:0;;;;;:::i;:::-;54178:4;54201:12;;;;;;;;;;;-1:-1:-1;;;;;54201:29:0;;;;;;;;;;;;;;;54101:136;74009:124;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;53434:49::-;;;;;;;;;;-1:-1:-1;53434:49:0;53479:4;53434:49;;74482:328;;;;;;;;;;-1:-1:-1;74482:328:0;;;;;:::i;:::-;;:::i;71733:168::-;;;;;;;;;;-1:-1:-1;71733:168:0;;;;;:::i;:::-;;:::i;74853:111::-;;;;;;;;;;;;;:::i;72358:278::-;;;;;;;;;;-1:-1:-1;72358:278:0;;;;;:::i;:::-;;:::i;74325:114::-;;;;;;;;;;-1:-1:-1;74325:114:0;;;;;:::i;:::-;74387:7;74413:19;;;:10;:19;;;;;;;74325:114;74176:106;;;;;;;;;;-1:-1:-1;74262:13:0;;-1:-1:-1;;;;;74262:13:0;74176:106;;73862:104;;;;;;;;;;-1:-1:-1;73942:17:0;;-1:-1:-1;;;;;73942:17:0;73862:104;;68927:131;;;;;;;;;;-1:-1:-1;68927:131:0;;;;;:::i;:::-;;:::i;71944:371::-;;;;;;;;;;-1:-1:-1;71944:371:0;;;;;:::i;:::-;;:::i;55889:138::-;;;;;;;;;;-1:-1:-1;55889:138:0;;;;;:::i;:::-;;:::i;71373:128::-;;;;;;;;;;-1:-1:-1;71373:128:0;;;;;:::i;:::-;;:::i;71016:149::-;;;;;;;;;;-1:-1:-1;71016:149:0;;;;;:::i;:::-;;:::i;67820:212::-;67905:4;67928:57;;;67943:42;67928:57;;:97;;;67989:36;68013:11;67989:23;:36::i;:::-;67921:104;67820:212;-1:-1:-1;;67820:212:0:o;72679:419::-;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;72783:27;;:32;;:67:::1;;-1:-1:-1::0;72819:26:0::1;::::0;::::1;::::0;:31;72783:67:::1;72779:193;;;72905:27:::0;;72934:26:::1;::::0;::::1;::::0;72873:88:::1;::::0;::::1;::::0;;::::1;::::0;::::1;9571:25:1::0;;;;9612:18;;;9605:34;9544:18;;72873:88:0::1;;;;;;;;72779:193;72981:24:::0;;:12:::1;:24:::0;;;::::1;::::0;;::::1;::::0;;;;;73020:71:::1;::::0;;9571:25:1;;;9612:18;;;9605:34;73020:71:0::1;::::0;9544:18:1;73020:71:0::1;;;;;;;;72679:419:::0;;:::o;71208:122::-;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;71302:21:::1;71316:6;71302:13;:21::i;:::-;71208:122:::0;;:::o;80504:528::-;80692:34;80729:207;80772:10;80808:9;80840:55;;;;;;;;80861:8;80840:55;;;;80883:10;80840:55;;;80918:7;;80729:207;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;80729:16:0;;-1:-1:-1;;;80729:207:0:i;:::-;80975:12;;;;;80989:15;;;;;81006:18;;80951:74;;9879:25:1;;;9920:18;;;9913:34;;;;9995:18;9983:31;9963:18;;;9956:59;10046:2;10031:18;;10024:34;80692:244:0;;-1:-1:-1;80951:74:0;;9866:3:1;9851:19;80951:74:0;;;;;;;;80682:350;80504:528;;;;;:::o;59684:180::-;59737:22;59761:24;59809:15;:13;:15::i;:::-;59797:27;;59844:13;:11;:13::i;:::-;59834:23;;59684:180;;:::o;55473:136::-;55122:7;55148:12;;;;;;;;;;:22;;;53711:16;53722:4;53711:10;:16::i;:::-;55577:25:::1;55588:4;55594:7;55577:10;:25::i;:::-;;55473:136:::0;;;:::o;56575:245::-;-1:-1:-1;;;;;56668:34:0;;17326:10;56668:34;56664:102;;56725:30;;;;;;;;;;;;;;56664:102;56776:37;56788:4;56794:18;56776:11;:37::i;:::-;;56575:245;;:::o;80298:136::-;53479:4;53711:16;53479:4;53711:10;:16::i;:::-;80366:61:::1;80392:10;80405:21;80366:17;:61::i;:::-;80298:136:::0;:::o;73141:196::-;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;73242:17:::1;:36:::0;;;::::1;-1:-1:-1::0;;;;;73242:36:0;::::1;::::0;;::::1;::::0;;;73293:37:::1;::::0;8250:74:1;;;73293:37:0::1;::::0;8238:2:1;8223:18;73293:37:0::1;8104:226:1::0;71544:146:0;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;71649:34:::1;71664:7;71673:9;71649:14;:34::i;58990:653::-:0;59204:31;59224:10;59204:19;:31::i;:::-;59199:116;;59258:46;;;;;59293:10;59258:46;;;8250:74:1;8223:18;;59258:46:0;8104:226:1;59199:116:0;59342:13;59328:10;:27;59324:103;;59378:38;;;;;;;;2122:25:1;;;2095:18;;59378:38:0;1976:177:1;59324:103:0;79459:4;79482:22;;;:10;:22;;;;;;:32;;59436:126;;59500:51;;;;;;;;9571:25:1;;;9612:18;;;9605:34;;;9544:18;;59500:51:0;9397:248:1;59436:126:0;59571:65;59587:10;59599:6;59607:7;59616:10;59628:7;;59571:15;:65::i;:::-;58990:653;;;;;;:::o;81118:324::-;81306:7;81336:99;81351:10;81363:55;;;;;;;;81384:8;81363:55;;;;81406:10;81363:55;;;81420:7;:14;81336;:99::i;:::-;81329:106;81118:324;-1:-1:-1;;;;;81118:324:0:o;68617:142::-;68698:7;68724:18;;;:12;:18;;;;;:28;;68746:5;68724:21;:28::i;:::-;68717:35;68617:142;-1:-1:-1;;;68617:142:0:o;74009:124::-;74064:16;74099:27;:18;:25;:27::i;:::-;74092:34;;74009:124;:::o;74482:328::-;74547:20;74599:19;;;:10;:19;;;;;;;-1:-1:-1;;;;;74685:29:0;;:44;;74681:123;;74752:41;;;;;;;;2122:25:1;;;2095:18;;74752:41:0;1976:177:1;74681:123:0;74569:241;74482:328;;;:::o;71733:168::-;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;71841:53:::1;71856:7:::0;-1:-1:-1;;;;;71865:26:0;::::1;71841:14;:53::i;74853:111::-:0;74898:16;74933:24;:15;:22;:24::i;72358:278::-;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;72449:12:::1;72464:30;:15;72487:6:::0;72464:22:::1;:30::i;:::-;72449:45;;72509:7;72504:83;;72539:37;::::0;::::1;::::0;;-1:-1:-1;;;;;8268:55:1;;72539:37:0::1;::::0;::::1;8250:74:1::0;8223:18;;72539:37:0::1;8104:226:1::0;72504:83:0::1;72601:28;::::0;-1:-1:-1;;;;;8268:55:1;;8250:74;;72601:28:0::1;::::0;8238:2:1;8223:18;72601:28:0::1;;;;;;;;72439:197;72358:278:::0;;:::o;68927:131::-;68998:7;69024:18;;;:12;:18;;;;;:27;;:25;:27::i;71944:371::-;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;-1:-1:-1;;;;;72036:20:0;::::1;72032:92;;72079:34;;;;;;;;;;;;;;72032:92;72133:10;72146:27;:15;72166:6:::0;72146:19:::1;:27::i;:::-;72133:40;;72188:5;72183:85;;72216:41;::::0;::::1;::::0;;-1:-1:-1;;;;;8268:55:1;;72216:41:0::1;::::0;::::1;8250:74:1::0;8223:18;;72216:41:0::1;8104:226:1::0;72183:85:0::1;72282:26;::::0;-1:-1:-1;;;;;8268:55:1;;8250:74;;72282:26:0::1;::::0;8238:2:1;8223:18;72282:26:0::1;8104:226:1::0;55889:138:0;55122:7;55148:12;;;;;;;;;;:22;;;53711:16;53722:4;53711:10;:16::i;:::-;55994:26:::1;56006:4;56012:7;55994:11;:26::i;71373:128::-:0;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;71470:24:::1;71487:6;71470:16;:24::i;71016:149::-:0;70160:29;53711:16;53722:4;53711:10;:16::i;:::-;71126:32:::1;71137:6;71145:12;71126:10;:32::i;53812:202::-:0;53897:4;53920:47;;;53935:32;53920:47;;:87;;-1:-1:-1;36722:25:0;36707:40;;;;53971:36;36608:146;54446:103;54512:30;54523:4;17326:10;54512;:30::i;61138:357::-;61201:27;61221:6;61201:19;:27::i;:::-;61196:108;;61251:42;;;;;-1:-1:-1;;;;;8268:55:1;;61251:42:0;;;8250:74:1;8223:18;;61251:42:0;8104:226:1;61196:108:0;61313:33;61332:6;61340:5;61313:18;:33::i;:::-;61361:31;;-1:-1:-1;;;;;8268:55:1;;8250:74;;61361:31:0;;8238:2:1;8223:18;61361:31:0;;;;;;;74262:13;;-1:-1:-1;;;;;74262:13:0;-1:-1:-1;;;;;61406:28:0;:6;-1:-1:-1;;;;;61406:28:0;;61402:87;;61450:28;61475:1;61450:16;:28::i;77258:405::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;77519:25:0;:7;:23;:25::i;:::-;77596:22;;;;:10;:22;;;;;;77489:55;;-1:-1:-1;77561:95:0;;77584:10;;77620;77489:55;77648:7;77561:22;:95::i;:::-;77554:102;77258:405;-1:-1:-1;;;;;;77258:405:0:o;78491:127::-;78579:30;;;;;;;;;:12;:30;;;;;;;;;78548:12;;78579:32;;:30;:32::i;69160:257::-;69246:4;69262:12;69277:31;69294:4;69300:7;69277:16;:31::i;:::-;69262:46;;69322:7;69318:69;;;69345:18;;;;:12;:18;;;;;:31;;69368:7;69345:22;:31::i;:::-;;69403:7;69160:257;-1:-1:-1;;;69160:257:0:o;69520:262::-;69607:4;69623:12;69638:32;69656:4;69662:7;69638:17;:32::i;:::-;69623:47;;69684:7;69680:72;;;69707:18;;;;:12;:18;;;;;:34;;69733:7;69707:25;:34::i;11858:331::-;11967:6;11943:21;:30;11939:109;;;11996:41;;;;;12031:4;11996:41;;;8250:74:1;8223:18;;11996:41:0;8104:226:1;11939:109:0;12059:12;12077:9;-1:-1:-1;;;;;12077:14:0;12099:6;12077:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12058:52;;;12125:7;12120:63;;12155:17;;;;;;;;;;;;;;75464:359;75558:13;75547:7;:24;75543:97;;75594:35;;;;;;;;2122:25:1;;;2095:18;;75594:35:0;1976:177:1;75543:97:0;75666:1;75653:14;;;75649:83;;75690:31;;;;;;;;;;;;;;75649:83;75741:19;;;;:10;:19;;;;;;:31;;;75787:29;75763:9;;75752:7;;75787:29;;75741:19;75787:29;75464:359;;:::o;79670:142::-;79747:4;79770:35;:18;79798:6;79770:27;:35::i;81562:292::-;81782:65;81798:10;81810:6;81818:7;81827:10;81839:7;;81782:65;;;;;;;;;;;:::i;78071:326::-;78238:7;78261:27;78291:25;:7;:23;:25::i;:::-;78261:55;;78333:57;78351:10;78363:14;78379:10;78333:17;:57::i;28029:156::-;28103:7;28153:22;28157:3;28169:5;28153:3;:22::i;28725:300::-;28788:16;28816:22;28841:19;28849:3;28841:7;:19::i;27089:156::-;27162:4;27185:53;27193:3;-1:-1:-1;;;;;27213:23:0;;27185:7;:53::i;27572:115::-;27635:7;27661:19;27669:3;23011:18;;22929:107;26771:150;26841:4;26864:50;26869:3;-1:-1:-1;;;;;26889:23:0;;26864:4;:50::i;61806:462::-;61944:27;61964:6;61944:19;:27::i;:::-;61943:28;:52;;;;-1:-1:-1;;;;;;61975:20:0;;;;61943:52;61939:132;;;62018:42;;;;;-1:-1:-1;;;;;8268:55:1;;62018:42:0;;;8250:74:1;8223:18;;62018:42:0;8104:226:1;61939:132:0;74262:13;;-1:-1:-1;;;;;74262:13:0;-1:-1:-1;;;;;62084:28:0;:6;-1:-1:-1;;;;;62084:28:0;;62080:108;;62135:42;;;;;-1:-1:-1;;;;;8268:55:1;;62135:42:0;;;8250:74:1;8223:18;;62135:42:0;8104:226:1;62080:108:0;76179:13;:22;;;;-1:-1:-1;;;;;76179:22:0;;;;;62238:23;;-1:-1:-1;;;;;8268:55:1;;8250:74;;62238:23:0;;8238:2:1;8223:18;62238:23:0;;;;;;;61806:462;:::o;60380:459::-;-1:-1:-1;;;;;60458:20:0;;60454:102;;60501:44;;;;;;;;;;;;;;60454:102;60569:27;60589:6;60569:19;:27::i;:::-;60565:106;;;60619:41;;;;;-1:-1:-1;;;;;8268:55:1;;60619:41:0;;;8250:74:1;8223:18;;60619:41:0;8104:226:1;60565:106:0;60680:32;60699:6;60707:4;60680:18;:32::i;:::-;60727:29;;-1:-1:-1;;;;;8268:55:1;;8250:74;;60727:29:0;;8238:2:1;8223:18;60727:29:0;;;;;;;60770:12;60766:67;;;60798:24;60815:6;60798:16;:24::i;54679:197::-;54178:4;54201:12;;;;;;;;;;;-1:-1:-1;;;;;54201:29:0;;;;;;;;;;;;54762:108;;54812:47;;;;;-1:-1:-1;;;;;11489:55:1;;54812:47:0;;;11471:74:1;11561:18;;;11554:34;;;11444:18;;54812:47:0;11297:297:1;76627:224:0;76717:7;76713:132;;;76740:30;:18;76763:6;76740:22;:30::i;76713:132::-;76801:33;:18;76827:6;76801:25;:33::i;34427:187::-;34501:12;34532:75;33488:1;34598:7;34587:19;;;;;;;;:::i;:::-;;;;;;;;;;;;;34532:42;:75::i;63965:973::-;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;64229:14:0;64246:18;74262:13;;-1:-1:-1;;;;;74262:13:0;;74176:106;64246:18;64229:35;-1:-1:-1;;;;;;64278:20:0;;64274:102;;64321:44;;;;;;;;;;;;;;64274:102;64403:13;64389:10;:27;64385:103;;64439:38;;;;;;;;2122:25:1;;;2095:18;;64439:38:0;1976:177:1;64385:103:0;64513:1;64501:13;;;64497:92;;64537:41;;;;;;;;2122:25:1;;;2095:18;;64537:41:0;1976:177:1;64497:92:0;64626:10;64602:21;:34;64598:155;;;64659:83;;;;;64697:21;64659:83;;;9571:25:1;9612:18;;;9605:34;;;9544:18;;64659:83:0;9397:248:1;64598:155:0;64789:6;-1:-1:-1;;;;;64769:42:0;;64819:10;64844;64856:8;64866:22;73942:17;;-1:-1:-1;;;;;73942:17:0;;73862:104;64866:22;64890:13;:11;:13::i;:::-;64905:7;64914;64769:162;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;64762:169;63965:973;-1:-1:-1;;;;;;;63965:973:0:o;57426:316::-;57503:4;54201:12;;;;;;;;;;;-1:-1:-1;;;;;54201:29:0;;;;;;;;;;;;57519:217;;57562:6;:12;;;;;;;;;;;-1:-1:-1;;;;;57562:29:0;;;;;;;;;:36;;;;57594:4;57562:36;;;57644:12;17326:10;;17247:96;57644:12;-1:-1:-1;;;;;57617:40:0;57635:7;-1:-1:-1;;;;;57617:40:0;57629:4;57617:40;;;;;;;;;;-1:-1:-1;57678:4:0;57671:11;;57519:217;-1:-1:-1;57720:5:0;57713:12;;57977:317;58055:4;54201:12;;;;;;;;;;;-1:-1:-1;;;;;54201:29:0;;;;;;;;;;;;58071:217;;;58145:5;58113:12;;;;;;;;;;;-1:-1:-1;;;;;58113:29:0;;;;;;;;;;:37;;;;;;58169:40;17326:10;;58113:12;;58169:40;;58145:5;58169:40;-1:-1:-1;58230:4:0;58223:11;;27326:165;-1:-1:-1;;;;;27459:23:0;;27406:4;22815:21;;;:14;;;:21;;;;;;:26;;27429:55;22719:129;65644:497;65810:7;65833:14;65850:18;74262:13;;-1:-1:-1;;;;;74262:13:0;;74176:106;65850:18;65833:35;-1:-1:-1;;;;;;65882:20:0;;65878:102;;65925:44;;;;;;;;;;;;;;65878:102;66016:6;-1:-1:-1;;;;;65996:44:0;;66054:10;66066:22;73942:17;;-1:-1:-1;;;;;73942:17:0;;73862:104;66066:22;66090:13;:11;:13::i;:::-;66105:7;66114:10;65996:138;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;23378:118::-;23445:7;23471:3;:11;;23483:5;23471:18;;;;;;;;:::i;:::-;;;;;;;;;23464:25;;23378:118;;;;:::o;24036:109::-;24092:16;24127:3;:11;;24120:18;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24036:109;;;:::o;21270:1368::-;21336:4;21465:21;;;:14;;;:21;;;;;;21501:13;;21497:1135;;21868:18;21889:12;21900:1;21889:8;:12;:::i;:::-;21935:18;;21868:33;;-1:-1:-1;21915:17:0;;21935:22;;21956:1;;21935:22;:::i;:::-;21915:42;;21990:9;21976:10;:23;21972:378;;22019:17;22039:3;:11;;22051:9;22039:22;;;;;;;;:::i;:::-;;;;;;;;;22019:42;;22186:9;22160:3;:11;;22172:10;22160:23;;;;;;;;:::i;:::-;;;;;;;;;;;;:35;;;;22299:25;;;:14;;;:25;;;;;:36;;;21972:378;22428:17;;:3;;:17;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;22531:3;:14;;:21;22546:5;22531:21;;;;;;;;;;;22524:28;;;22574:4;22567:11;;;;;;;21497:1135;22616:5;22609:12;;;;;20696:406;20759:4;22815:21;;;:14;;;:21;;;;;;20775:321;;-1:-1:-1;20817:23:0;;;;;;;;:11;:23;;;;;;;;;;;;;20999:18;;20975:21;;;:14;;;:21;;;;;;:42;;;;21031:11;;3752:165;3845:12;3893:7;3902;3876:34;;;;;;;;;:::i;:::-;;;;;;;;;;;;;3869:41;;3752:165;;;;:::o;14:332:1:-;72:6;125:2;113:9;104:7;100:23;96:32;93:52;;;141:1;138;131:12;93:52;180:9;167:23;230:66;223:5;219:78;212:5;209:89;199:117;;312:1;309;302:12;543:184;595:77;592:1;585:88;692:4;689:1;682:15;716:4;713:1;706:15;732:334;803:2;797:9;859:2;849:13;;864:66;845:86;833:99;;962:18;947:34;;983:22;;;944:62;941:88;;;1009:18;;:::i;:::-;1045:2;1038:22;732:334;;-1:-1:-1;732:334:1:o;1071:508::-;1159:6;1212:2;1200:9;1191:7;1187:23;1183:32;1180:52;;;1228:1;1225;1218:12;1180:52;1261:2;1255:9;1303:2;1295:6;1291:15;1372:6;1360:10;1357:22;1336:18;1324:10;1321:34;1318:62;1315:88;;;1383:18;;:::i;:::-;1419:2;1412:22;1458:23;;1443:39;;1543:2;1528:18;;;1515:32;1498:15;;;1491:57;;;;-1:-1:-1;1450:6:1;1071:508;-1:-1:-1;1071:508:1:o;1584:196::-;1652:20;;-1:-1:-1;;;;;1701:54:1;;1691:65;;1681:93;;1770:1;1767;1760:12;1681:93;1584:196;;;:::o;1785:186::-;1844:6;1897:2;1885:9;1876:7;1872:23;1868:32;1865:52;;;1913:1;1910;1903:12;1865:52;1936:29;1955:9;1936:29;:::i;2158:180::-;2217:6;2270:2;2258:9;2249:7;2245:23;2241:32;2238:52;;;2286:1;2283;2276:12;2238:52;-1:-1:-1;2309:23:1;;2158:180;-1:-1:-1;2158:180:1:o;2343:347::-;2394:8;2404:6;2458:3;2451:4;2443:6;2439:17;2435:27;2425:55;;2476:1;2473;2466:12;2425:55;-1:-1:-1;2499:20:1;;2542:18;2531:30;;2528:50;;;2574:1;2571;2564:12;2528:50;2611:4;2603:6;2599:17;2587:29;;2663:3;2656:4;2647:6;2639;2635:19;2631:30;2628:39;2625:59;;;2680:1;2677;2670:12;2625:59;2343:347;;;;;:::o;2695:614::-;2792:6;2800;2808;2816;2824;2877:3;2865:9;2856:7;2852:23;2848:33;2845:53;;;2894:1;2891;2884:12;2845:53;2930:9;2917:23;2907:33;;2987:2;2976:9;2972:18;2959:32;2949:42;;3038:2;3027:9;3023:18;3010:32;3000:42;;3093:2;3082:9;3078:18;3065:32;3120:18;3112:6;3109:30;3106:50;;;3152:1;3149;3142:12;3106:50;3191:58;3241:7;3232:6;3221:9;3217:22;3191:58;:::i;:::-;2695:614;;;;-1:-1:-1;2695:614:1;;-1:-1:-1;3268:8:1;;3165:84;2695:614;-1:-1:-1;;;2695:614:1:o;3314:250::-;3399:1;3409:113;3423:6;3420:1;3417:13;3409:113;;;3499:11;;;3493:18;3480:11;;;3473:39;3445:2;3438:10;3409:113;;;-1:-1:-1;;3556:1:1;3538:16;;3531:27;3314:250::o;3569:329::-;3610:3;3648:5;3642:12;3675:6;3670:3;3663:19;3691:76;3760:6;3753:4;3748:3;3744:14;3737:4;3730:5;3726:16;3691:76;:::i;:::-;3812:2;3800:15;3817:66;3796:88;3787:98;;;;3887:4;3783:109;;3569:329;-1:-1:-1;;3569:329:1:o;3903:484::-;3956:3;3994:5;3988:12;4021:6;4016:3;4009:19;4047:4;4076:2;4071:3;4067:12;4060:19;;4113:2;4106:5;4102:14;4134:1;4144:218;4158:6;4155:1;4152:13;4144:218;;;4223:13;;-1:-1:-1;;;;;4219:62:1;4207:75;;4302:12;;;;4337:15;;;;4180:1;4173:9;4144:218;;;-1:-1:-1;4378:3:1;;3903:484;-1:-1:-1;;;;;3903:484:1:o;4392:421::-;4617:2;4606:9;4599:21;4580:4;4643:44;4683:2;4672:9;4668:18;4660:6;4643:44;:::i;:::-;4735:9;4727:6;4723:22;4718:2;4707:9;4703:18;4696:50;4763:44;4800:6;4792;4763:44;:::i;4818:254::-;4886:6;4894;4947:2;4935:9;4926:7;4922:23;4918:32;4915:52;;;4963:1;4960;4953:12;4915:52;4999:9;4986:23;4976:33;;5028:38;5062:2;5051:9;5047:18;5028:38;:::i;:::-;5018:48;;4818:254;;;;;:::o;5077:248::-;5145:6;5153;5206:2;5194:9;5185:7;5181:23;5177:32;5174:52;;;5222:1;5219;5212:12;5174:52;-1:-1:-1;;5245:23:1;;;5315:2;5300:18;;;5287:32;;-1:-1:-1;5077:248:1:o;5330:129::-;5415:18;5408:5;5404:30;5397:5;5394:41;5384:69;;5449:1;5446;5439:12;5464:748;5569:6;5577;5585;5593;5601;5609;5662:3;5650:9;5641:7;5637:23;5633:33;5630:53;;;5679:1;5676;5669:12;5630:53;5715:9;5702:23;5692:33;;5772:2;5761:9;5757:18;5744:32;5734:42;;5823:2;5812:9;5808:18;5795:32;5785:42;;5877:2;5866:9;5862:18;5849:32;5890:30;5914:5;5890:30;:::i;:::-;5939:5;-1:-1:-1;5995:3:1;5980:19;;5967:33;6023:18;6012:30;;6009:50;;;6055:1;6052;6045:12;6009:50;6094:58;6144:7;6135:6;6124:9;6120:22;6094:58;:::i;:::-;5464:748;;;;-1:-1:-1;5464:748:1;;-1:-1:-1;5464:748:1;;6171:8;;5464:748;-1:-1:-1;;;5464:748:1:o;6217:1027::-;6312:6;6320;6328;6336;6389:3;6377:9;6368:7;6364:23;6360:33;6357:53;;;6406:1;6403;6396:12;6357:53;6442:9;6429:23;6419:33;;6471:2;6520;6509:9;6505:18;6492:32;6482:42;;6571:2;6560:9;6556:18;6543:32;6533:42;;6626:2;6615:9;6611:18;6598:32;6649:18;6690:2;6682:6;6679:14;6676:34;;;6706:1;6703;6696:12;6676:34;6744:6;6733:9;6729:22;6719:32;;6789:7;6782:4;6778:2;6774:13;6770:27;6760:55;;6811:1;6808;6801:12;6760:55;6847:2;6834:16;6869:2;6865;6862:10;6859:36;;;6875:18;;:::i;:::-;6917:112;7025:2;6956:66;6949:4;6945:2;6941:13;6937:86;6933:95;6917:112;:::i;:::-;6904:125;;7052:2;7045:5;7038:17;7092:7;7087:2;7082;7078;7074:11;7070:20;7067:33;7064:53;;;7113:1;7110;7103:12;7064:53;7168:2;7163;7159;7155:11;7150:2;7143:5;7139:14;7126:45;7212:1;7207:2;7202;7195:5;7191:14;7187:23;7180:34;;7233:5;7223:15;;;;;6217:1027;;;;;;;:::o;7588:258::-;7508:12;;7496:25;;7570:4;7559:16;;;7553:23;7537:14;;;7530:47;7780:2;7765:18;;7792:48;7431:152;8335:261;8514:2;8503:9;8496:21;8477:4;8534:56;8586:2;8575:9;8571:18;8563:6;8534:56;:::i;9045:347::-;9110:6;9118;9171:2;9159:9;9150:7;9146:23;9142:32;9139:52;;;9187:1;9184;9177:12;9139:52;9210:29;9229:9;9210:29;:::i;:::-;9200:39;;9289:2;9278:9;9274:18;9261:32;9336:5;9329:13;9322:21;9315:5;9312:32;9302:60;;9358:1;9355;9348:12;9302:60;9381:5;9371:15;;;9045:347;;;;;:::o;10532:760::-;10799:6;10788:9;10781:25;10842:6;10837:2;10826:9;10822:18;10815:34;10885:6;10880:2;10869:9;10865:18;10858:34;10940:18;10932:6;10928:31;10923:2;10912:9;10908:18;10901:59;10997:3;10991;10980:9;10976:19;10969:32;11038:6;11032:3;11021:9;11017:19;11010:35;11096:6;11088;11082:3;11071:9;11067:19;11054:49;11153:1;11123:22;;;11147:3;11119:32;;;11112:43;;;;11207:2;11195:15;;;11212:66;11191:88;11176:104;11172:114;;10532:760;-1:-1:-1;;;;;10532:760:1:o;11858:847::-;12213:6;12202:9;12195:25;12256:6;12251:2;12240:9;12236:18;12229:34;-1:-1:-1;;;;;12303:6:1;12299:55;12294:2;12283:9;12279:18;12272:83;12391:3;12386:2;12375:9;12371:18;12364:31;12176:4;12418:57;12470:3;12459:9;12455:19;12447:6;12418:57;:::i;:::-;12524:9;12516:6;12512:22;12506:3;12495:9;12491:19;12484:51;12558:32;12583:6;12575;12558:32;:::i;:::-;12544:46;;12639:9;12631:6;12627:22;12621:3;12610:9;12606:19;12599:51;12667:32;12692:6;12684;12667:32;:::i;:::-;12659:40;11858:847;-1:-1:-1;;;;;;;;;11858:847:1:o;12710:641::-;12820:6;12873:2;12861:9;12852:7;12848:23;12844:32;12841:52;;;12889:1;12886;12879:12;12841:52;12922:2;12916:9;12964:2;12956:6;12952:15;13033:6;13021:10;13018:22;12997:18;12985:10;12982:34;12979:62;12976:88;;;13044:18;;:::i;:::-;13084:10;13080:2;13073:22;;13125:9;13119:16;13111:6;13104:32;13190:2;13179:9;13175:18;13169:25;13164:2;13156:6;13152:15;13145:50;13238:2;13227:9;13223:18;13217:25;13251:30;13275:5;13251:30;:::i;:::-;13309:2;13297:15;;13290:30;13301:6;12710:641;-1:-1:-1;;;12710:641:1:o;13356:686::-;13665:6;13654:9;13647:25;-1:-1:-1;;;;;13712:6:1;13708:55;13703:2;13692:9;13688:18;13681:83;13800:3;13795:2;13784:9;13780:18;13773:31;13628:4;13827:57;13879:3;13868:9;13864:19;13856:6;13827:57;:::i;:::-;13932:9;13924:6;13920:22;13915:2;13904:9;13900:18;13893:50;13960:32;13985:6;13977;13960:32;:::i;:::-;13952:40;;;14029:6;14023:3;14012:9;14008:19;14001:35;13356:686;;;;;;;;:::o;14047:184::-;14117:6;14170:2;14158:9;14149:7;14145:23;14141:32;14138:52;;;14186:1;14183;14176:12;14138:52;-1:-1:-1;14209:16:1;;14047:184;-1:-1:-1;14047:184:1:o;14236:::-;14288:77;14285:1;14278:88;14385:4;14382:1;14375:15;14409:4;14406:1;14399:15;14425:282;14492:9;;;14513:11;;;14510:191;;;14557:77;14554:1;14547:88;14658:4;14655:1;14648:15;14686:4;14683:1;14676:15;14712:184;14764:77;14761:1;14754:88;14861:4;14858:1;14851:15;14885:4;14882:1;14875:15;14901:440;15108:66;15099:6;15094:3;15090:16;15086:89;15081:3;15074:102;15056:3;15205:6;15199:13;15221:74;15288:6;15284:1;15279:3;15275:11;15268:4;15260:6;15256:17;15221:74;:::i;:::-;15315:16;;;;15333:1;15311:24;;14901:440;-1:-1:-1;;;14901:440:1:o","abiDefinition":[{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__AlreadyLatestClient","type":"error"},{"inputs":[],"name":"InterchainApp__AppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainApp__BalanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__ClientAlreadyAdded","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"InterchainApp__InvalidAppConfig","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__NotEVMLinkedApp","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__ReceiverNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__SameChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"srcChainId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"sender","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"message","type":"bytes"}],"name":"MessageReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"dstChainId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dbNonce","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"entryIndex","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"MessageSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"linkedAppEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"getMessageFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"sendMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"appConfig","type":"tuple"}],"name":"setAppConfigV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"IC_GOVERNOR_ROLE()":{"notice":"Role to manage the Interchain setup of the app."},"addInterchainClient(address,bool)":{"notice":"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app."},"addTrustedModule(address)":{"notice":"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages."},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getAppConfigV1()":{"notice":"Returns the app config for the current app: requiredResponses and optimisticPeriod."},"getExecutionService()":{"notice":"Returns the address of the Execution Service used by this app for sending messages."},"getInterchainClients()":{"notice":"Returns the list of Interchain Clients allowed to send messages to this app."},"getLatestInterchainClient()":{"notice":"Returns the address of the latest interchain client. This address is used for sending messages from this app."},"getLinkedApp(uint256)":{"notice":"Returns the linked app address (as bytes32) for the given chain ID."},"getLinkedAppEVM(uint256)":{"notice":"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address."},"getMessageFee(uint256,uint256,uint256,bytes)":{"notice":"Returns the fee required to send a message using `sendMessage`."},"getModules()":{"notice":"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."},"linkRemoteApp(uint256,bytes32)":{"notice":"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain."},"linkRemoteAppEVM(uint256,address)":{"notice":"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter."},"removeInterchainClient(address)":{"notice":"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address."},"removeTrustedModule(address)":{"notice":"Allows the owner to remove the module from the trusted modules set."},"sendMessage(uint256,uint256,uint256,bytes)":{"notice":"Sends a basic message to the destination chain."},"setAppConfigV1((uint256,uint256))":{"notice":"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final"},"setExecutionService(address)":{"notice":"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee."},"setLatestInterchainClient(address)":{"notice":"Allows the owner to set the address of the latest interchain client."},"withdraw()":{"notice":"Allows the Admin to withdraw the native asset from the contract."}},"version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}],"AddressInsufficientBalance(address)":[{"details":"The ETH balance of the account is not enough to perform the operation."}],"FailedInnerCall()":[{"details":"A call to an address target failed. The target may have reverted."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"addInterchainClient(address,bool)":{"params":{"client":"The address of the interchain client to add.","updateLatest":"Whether to set the latest client to this one."}},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getLinkedAppEVM(uint256)":{"details":"Will revert if the linked app address is not an EVM address."},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"linkRemoteApp(uint256,bytes32)":{"params":{"chainId":"The remote chain ID.","remoteApp":"The address of the remote app to link."}},"removeInterchainClient(address)":{"params":{"client":"The address of the interchain client to remove."}},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"setLatestInterchainClient(address)":{"details":"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.","params":{"client":"The address of the latest interchain client."}},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"admin\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__AlreadyLatestClient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__AppZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__BalanceTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__ClientAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__InterchainClientZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__InvalidAppConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__ModuleZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"linkedApp\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__NotEVMLinkedApp\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"InterchainApp__NotInterchainClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__ReceiverNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__SenderNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"AppConfigV1Set\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"AppLinked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"ExecutionServiceSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"MessageReceived\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"MessageSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleRemoved\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"updateLatest\",\"type\":\"bool\"}],\"name\":\"addInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"addTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAppConfigV1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExecutionService\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInterchainClients\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestInterchainClient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedApp\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedAppEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedAppEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"getMessageFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"linkRemoteApp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"remoteApp\",\"type\":\"address\"}],\"name\":\"linkRemoteAppEVM\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"removeInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"removeTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"sendMessage\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"appConfig\",\"type\":\"tuple\"}],\"name\":\"setAppConfigV1\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"setExecutionService\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"setLatestInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"addInterchainClient(address,bool)\":{\"params\":{\"client\":\"The address of the interchain client to add.\",\"updateLatest\":\"Whether to set the latest client to this one.\"}},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getLinkedAppEVM(uint256)\":{\"details\":\"Will revert if the linked app address is not an EVM address.\"},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"linkRemoteApp(uint256,bytes32)\":{\"params\":{\"chainId\":\"The remote chain ID.\",\"remoteApp\":\"The address of the remote app to link.\"}},\"removeInterchainClient(address)\":{\"params\":{\"client\":\"The address of the interchain client to remove.\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setLatestInterchainClient(address)\":{\"details\":\"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.\",\"params\":{\"client\":\"The address of the latest interchain client.\"}},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"IC_GOVERNOR_ROLE()\":{\"notice\":\"Role to manage the Interchain setup of the app.\"},\"addInterchainClient(address,bool)\":{\"notice\":\"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app.\"},\"addTrustedModule(address)\":{\"notice\":\"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages.\"},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getAppConfigV1()\":{\"notice\":\"Returns the app config for the current app: requiredResponses and optimisticPeriod.\"},\"getExecutionService()\":{\"notice\":\"Returns the address of the Execution Service used by this app for sending messages.\"},\"getInterchainClients()\":{\"notice\":\"Returns the list of Interchain Clients allowed to send messages to this app.\"},\"getLatestInterchainClient()\":{\"notice\":\"Returns the address of the latest interchain client. This address is used for sending messages from this app.\"},\"getLinkedApp(uint256)\":{\"notice\":\"Returns the linked app address (as bytes32) for the given chain ID.\"},\"getLinkedAppEVM(uint256)\":{\"notice\":\"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\"},\"getMessageFee(uint256,uint256,uint256,bytes)\":{\"notice\":\"Returns the fee required to send a message using `sendMessage`.\"},\"getModules()\":{\"notice\":\"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"},\"linkRemoteApp(uint256,bytes32)\":{\"notice\":\"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain.\"},\"linkRemoteAppEVM(uint256,address)\":{\"notice\":\"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\"},\"removeInterchainClient(address)\":{\"notice\":\"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address.\"},\"removeTrustedModule(address)\":{\"notice\":\"Allows the owner to remove the module from the trusted modules set.\"},\"sendMessage(uint256,uint256,uint256,bytes)\":{\"notice\":\"Sends a basic message to the destination chain.\"},\"setAppConfigV1((uint256,uint256))\":{\"notice\":\"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final\"},\"setExecutionService(address)\":{\"notice\":\"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee.\"},\"setLatestInterchainClient(address)\":{\"notice\":\"Allows the owner to set the address of the latest interchain client.\"},\"withdraw()\":{\"notice\":\"Allows the Admin to withdraw the native asset from the contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"ExampleAppV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","IC_GOVERNOR_ROLE()":"1c489e4f","addInterchainClient(address,bool)":"f22ba23d","addTrustedModule(address)":"cb5038fb","appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getAppConfigV1()":"7717a647","getExecutionService()":"c313c807","getInterchainClients()":"a1aa5d68","getLatestInterchainClient()":"bc0d912c","getLinkedApp(uint256)":"b9b74b18","getLinkedAppEVM(uint256)":"a9ac04b6","getMessageFee(uint256,uint256,uint256,bytes)":"764ca1e8","getModules()":"b2494df3","getReceivingConfig()":"287bc057","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","linkRemoteApp(uint256,bytes32)":"51a30802","linkRemoteAppEVM(uint256,address)":"af8fcc8e","removeInterchainClient(address)":"0fb59156","removeTrustedModule(address)":"b70c40b3","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","sendMessage(uint256,uint256,uint256,bytes)":"282be0e9","setAppConfigV1((uint256,uint256))":"0d32b505","setExecutionService(address)":"496774b1","setLatestInterchainClient(address)":"eb53b44e","supportsInterface(bytes4)":"01ffc9a7","withdraw()":"3ccfd60b"}},"solidity/ExampleAppV1.sol:IAccessControl":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"External interface of AccessControl declared to support ERC165 detection.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"External interface of AccessControl declared to support ERC165 detection.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IAccessControl\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"getRoleAdmin(bytes32)":"248a9ca3","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"solidity/ExampleAppV1.sol:IAccessControlEnumerable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"External interface of AccessControlEnumerable declared to support ERC165 detection.","errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"External interface of AccessControlEnumerable declared to support ERC165 detection.\",\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {AccessControl-_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IAccessControlEnumerable\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f"}},"solidity/ExampleAppV1.sol:ICAppV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__AlreadyLatestClient","type":"error"},{"inputs":[],"name":"InterchainApp__AppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainApp__BalanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"InterchainApp__ClientAlreadyAdded","type":"error"},{"inputs":[],"name":"InterchainApp__InterchainClientZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"InterchainApp__InvalidAppConfig","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__NotEVMLinkedApp","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"InterchainApp__NotInterchainClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__ReceiverNotSet","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainApp__SameChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"InterchainApp__SenderNotAllowed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"InterchainClientRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"client","type":"address"}],"name":"LatestClientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IC_GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"linkedAppEVM","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"appConfig","type":"tuple"}],"name":"setAppConfigV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"IC_GOVERNOR_ROLE()":{"notice":"Role to manage the Interchain setup of the app."},"addInterchainClient(address,bool)":{"notice":"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app."},"addTrustedModule(address)":{"notice":"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages."},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getAppConfigV1()":{"notice":"Returns the app config for the current app: requiredResponses and optimisticPeriod."},"getExecutionService()":{"notice":"Returns the address of the Execution Service used by this app for sending messages."},"getInterchainClients()":{"notice":"Returns the list of Interchain Clients allowed to send messages to this app."},"getLatestInterchainClient()":{"notice":"Returns the address of the latest interchain client. This address is used for sending messages from this app."},"getLinkedApp(uint256)":{"notice":"Returns the linked app address (as bytes32) for the given chain ID."},"getLinkedAppEVM(uint256)":{"notice":"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address."},"getModules()":{"notice":"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."},"linkRemoteApp(uint256,bytes32)":{"notice":"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain."},"linkRemoteAppEVM(uint256,address)":{"notice":"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter."},"removeInterchainClient(address)":{"notice":"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address."},"removeTrustedModule(address)":{"notice":"Allows the owner to remove the module from the trusted modules set."},"setAppConfigV1((uint256,uint256))":{"notice":"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final"},"setExecutionService(address)":{"notice":"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee."},"setLatestInterchainClient(address)":{"notice":"Allows the owner to set the address of the latest interchain client."}},"version":1},"developerDoc":{"errors":{"AccessControlBadConfirmation()":[{"details":"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}."}],"AccessControlUnauthorizedAccount(address,bytes32)":[{"details":"The `account` is missing a role."}]},"events":{"RoleAdminChanged(bytes32,bytes32,bytes32)":{"details":"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this."},"RoleGranted(bytes32,address,address)":{"details":"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}."},"RoleRevoked(bytes32,address,address)":{"details":"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)"}},"kind":"dev","methods":{"addInterchainClient(address,bool)":{"params":{"client":"The address of the interchain client to add.","updateLatest":"Whether to set the latest client to this one."}},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getLinkedAppEVM(uint256)":{"details":"Will revert if the linked app address is not an EVM address."},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}},"getRoleAdmin(bytes32)":{"details":"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}."},"getRoleMember(bytes32,uint256)":{"details":"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information."},"getRoleMemberCount(bytes32)":{"details":"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role."},"grantRole(bytes32,address)":{"details":"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event."},"hasRole(bytes32,address)":{"details":"Returns `true` if `account` has been granted `role`."},"linkRemoteApp(uint256,bytes32)":{"params":{"chainId":"The remote chain ID.","remoteApp":"The address of the remote app to link."}},"removeInterchainClient(address)":{"params":{"client":"The address of the interchain client to remove."}},"renounceRole(bytes32,address)":{"details":"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event."},"revokeRole(bytes32,address)":{"details":"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event."},"setLatestInterchainClient(address)":{"details":"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.","params":{"client":"The address of the latest interchain client."}},"supportsInterface(bytes4)":{"details":"See {IERC165-supportsInterface}."}},"stateVariables":{"_appConfigV1":{"details":"Required responses and optimistic period for the module responses."},"_executionService":{"details":"Execution Service to use for sending messages."},"_interchainClients":{"details":"Interchain Clients allowed to send messages to this app."},"_latestClient":{"details":"Address of the latest Interchain Client, used for sending messages."},"_linkedApp":{"details":"Address of the linked app deployed on the remote chain."},"_trustedModules":{"details":"Trusted Interchain modules."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AccessControlBadConfirmation\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"neededRole\",\"type\":\"bytes32\"}],\"name\":\"AccessControlUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__AlreadyLatestClient\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__AppZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__BalanceTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainApp__ClientAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__InterchainClientZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__InvalidAppConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__ModuleZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"linkedApp\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__NotEVMLinkedApp\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"InterchainApp__NotInterchainClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__ReceiverNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__SameChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__SenderNotAllowed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"AppConfigV1Set\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"AppLinked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"ExecutionServiceSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"InterchainClientRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"LatestClientSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleRemoved\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IC_GOVERNOR_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"updateLatest\",\"type\":\"bool\"}],\"name\":\"addInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"addTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAppConfigV1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExecutionService\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInterchainClients\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestInterchainClient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedApp\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedAppEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"linkedAppEVM\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getRoleMember\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleMemberCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"linkRemoteApp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"remoteApp\",\"type\":\"address\"}],\"name\":\"linkRemoteAppEVM\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"removeInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"removeTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"callerConfirmation\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"appConfig\",\"type\":\"tuple\"}],\"name\":\"setAppConfigV1\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"setExecutionService\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"setLatestInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AccessControlBadConfirmation()\":[{\"details\":\"The caller of a function is not the expected one. NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\"}],\"AccessControlUnauthorizedAccount(address,bytes32)\":[{\"details\":\"The `account` is missing a role.\"}]},\"events\":{\"RoleAdminChanged(bytes32,bytes32,bytes32)\":{\"details\":\"Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite {RoleAdminChanged} not being emitted signaling this.\"},\"RoleGranted(bytes32,address,address)\":{\"details\":\"Emitted when `account` is granted `role`. `sender` is the account that originated the contract call, an admin role bearer except when using {AccessControl-_setupRole}.\"},\"RoleRevoked(bytes32,address,address)\":{\"details\":\"Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call: - if using `revokeRole`, it is the admin role bearer - if using `renounceRole`, it is the role bearer (i.e. `account`)\"}},\"kind\":\"dev\",\"methods\":{\"addInterchainClient(address,bool)\":{\"params\":{\"client\":\"The address of the interchain client to add.\",\"updateLatest\":\"Whether to set the latest client to this one.\"}},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getLinkedAppEVM(uint256)\":{\"details\":\"Will revert if the linked app address is not an EVM address.\"},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}},\"getRoleAdmin(bytes32)\":{\"details\":\"Returns the admin role that controls `role`. See {grantRole} and {revokeRole}. To change a role's admin, use {_setRoleAdmin}.\"},\"getRoleMember(bytes32,uint256)\":{\"details\":\"Returns one of the accounts that have `role`. `index` must be a value between 0 and {getRoleMemberCount}, non-inclusive. Role bearers are not sorted in any particular way, and their ordering may change at any point. WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure you perform all queries on the same block. See the following https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] for more information.\"},\"getRoleMemberCount(bytes32)\":{\"details\":\"Returns the number of accounts that have `role`. Can be used together with {getRoleMember} to enumerate all bearers of a role.\"},\"grantRole(bytes32,address)\":{\"details\":\"Grants `role` to `account`. If `account` had not been already granted `role`, emits a {RoleGranted} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleGranted} event.\"},\"hasRole(bytes32,address)\":{\"details\":\"Returns `true` if `account` has been granted `role`.\"},\"linkRemoteApp(uint256,bytes32)\":{\"params\":{\"chainId\":\"The remote chain ID.\",\"remoteApp\":\"The address of the remote app to link.\"}},\"removeInterchainClient(address)\":{\"params\":{\"client\":\"The address of the interchain client to remove.\"}},\"renounceRole(bytes32,address)\":{\"details\":\"Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function's purpose is to provide a mechanism for accounts to lose their privileges if they are compromised (such as when a trusted device is misplaced). If the calling account had been revoked `role`, emits a {RoleRevoked} event. Requirements: - the caller must be `callerConfirmation`. May emit a {RoleRevoked} event.\"},\"revokeRole(bytes32,address)\":{\"details\":\"Revokes `role` from `account`. If `account` had been granted `role`, emits a {RoleRevoked} event. Requirements: - the caller must have ``role``'s admin role. May emit a {RoleRevoked} event.\"},\"setLatestInterchainClient(address)\":{\"details\":\"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.\",\"params\":{\"client\":\"The address of the latest interchain client.\"}},\"supportsInterface(bytes4)\":{\"details\":\"See {IERC165-supportsInterface}.\"}},\"stateVariables\":{\"_appConfigV1\":{\"details\":\"Required responses and optimistic period for the module responses.\"},\"_executionService\":{\"details\":\"Execution Service to use for sending messages.\"},\"_interchainClients\":{\"details\":\"Interchain Clients allowed to send messages to this app.\"},\"_latestClient\":{\"details\":\"Address of the latest Interchain Client, used for sending messages.\"},\"_linkedApp\":{\"details\":\"Address of the linked app deployed on the remote chain.\"},\"_trustedModules\":{\"details\":\"Trusted Interchain modules.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"IC_GOVERNOR_ROLE()\":{\"notice\":\"Role to manage the Interchain setup of the app.\"},\"addInterchainClient(address,bool)\":{\"notice\":\"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app.\"},\"addTrustedModule(address)\":{\"notice\":\"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages.\"},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getAppConfigV1()\":{\"notice\":\"Returns the app config for the current app: requiredResponses and optimisticPeriod.\"},\"getExecutionService()\":{\"notice\":\"Returns the address of the Execution Service used by this app for sending messages.\"},\"getInterchainClients()\":{\"notice\":\"Returns the list of Interchain Clients allowed to send messages to this app.\"},\"getLatestInterchainClient()\":{\"notice\":\"Returns the address of the latest interchain client. This address is used for sending messages from this app.\"},\"getLinkedApp(uint256)\":{\"notice\":\"Returns the linked app address (as bytes32) for the given chain ID.\"},\"getLinkedAppEVM(uint256)\":{\"notice\":\"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\"},\"getModules()\":{\"notice\":\"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"},\"linkRemoteApp(uint256,bytes32)\":{\"notice\":\"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain.\"},\"linkRemoteAppEVM(uint256,address)\":{\"notice\":\"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\"},\"removeInterchainClient(address)\":{\"notice\":\"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address.\"},\"removeTrustedModule(address)\":{\"notice\":\"Allows the owner to remove the module from the trusted modules set.\"},\"setAppConfigV1((uint256,uint256))\":{\"notice\":\"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final\"},\"setExecutionService(address)\":{\"notice\":\"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee.\"},\"setLatestInterchainClient(address)\":{\"notice\":\"Allows the owner to set the address of the latest interchain client.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"ICAppV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"DEFAULT_ADMIN_ROLE()":"a217fddf","IC_GOVERNOR_ROLE()":"1c489e4f","addInterchainClient(address,bool)":"f22ba23d","addTrustedModule(address)":"cb5038fb","appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getAppConfigV1()":"7717a647","getExecutionService()":"c313c807","getInterchainClients()":"a1aa5d68","getLatestInterchainClient()":"bc0d912c","getLinkedApp(uint256)":"b9b74b18","getLinkedAppEVM(uint256)":"a9ac04b6","getModules()":"b2494df3","getReceivingConfig()":"287bc057","getRoleAdmin(bytes32)":"248a9ca3","getRoleMember(bytes32,uint256)":"9010d07c","getRoleMemberCount(bytes32)":"ca15c873","grantRole(bytes32,address)":"2f2ff15d","hasRole(bytes32,address)":"91d14854","linkRemoteApp(uint256,bytes32)":"51a30802","linkRemoteAppEVM(uint256,address)":"af8fcc8e","removeInterchainClient(address)":"0fb59156","removeTrustedModule(address)":"b70c40b3","renounceRole(bytes32,address)":"36568abe","revokeRole(bytes32,address)":"d547741f","setAppConfigV1((uint256,uint256))":"0d32b505","setExecutionService(address)":"496774b1","setLatestInterchainClient(address)":"eb53b44e","supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:IERC165":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.","kind":"dev","methods":{"supportsInterface(bytes4)":{"details":"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Interface of the ERC165 standard, as defined in the https://eips.ethereum.org/EIPS/eip-165[EIP]. Implementers can declare support of contract interfaces, which can then be queried by others ({ERC165Checker}). For an implementation, see {ERC165}.\",\"kind\":\"dev\",\"methods\":{\"supportsInterface(bytes4)\":{\"details\":\"Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IERC165\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"supportsInterface(bytes4)":"01ffc9a7"}},"solidity/ExampleAppV1.sol:IInterchainApp":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."}},"notice":"Minimal interface for the Interchain App to work with the Interchain Client.","version":1},"developerDoc":{"kind":"dev","methods":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"}},\"notice\":\"Minimal interface for the Interchain App to work with the Interchain Client.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IInterchainApp\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getReceivingConfig()":"287bc057"}},"solidity/ExampleAppV1.sol:IInterchainAppV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"InterchainApp__AppZeroAddress","type":"error"},{"inputs":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"InterchainApp__InvalidAppConfig","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleAlreadyAdded","type":"error"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"InterchainApp__ModuleNotAdded","type":"error"},{"inputs":[],"name":"InterchainApp__ModuleZeroAddress","type":"error"},{"inputs":[{"internalType":"bytes32","name":"linkedApp","type":"bytes32"}],"name":"InterchainApp__NotEVMLinkedApp","type":"error"},{"inputs":[{"internalType":"address","name":"client","type":"address"},{"internalType":"bool","name":"updateLatest","type":"bool"}],"name":"addInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"addTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"srcChainId","type":"uint256"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"appReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAppConfigV1","outputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExecutionService","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInterchainClients","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestInterchainClient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedApp","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedAppEVM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getModules","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReceivingConfig","outputs":[{"internalType":"bytes","name":"appConfig","type":"bytes"},{"internalType":"address[]","name":"modules","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"linkRemoteApp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"remoteApp","type":"address"}],"name":"linkRemoteAppEVM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"removeInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"removeTrustedModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"internalType":"struct AppConfigV1","name":"appConfig","type":"tuple"}],"name":"setAppConfigV1","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"executionService","type":"address"}],"name":"setExecutionService","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"client","type":"address"}],"name":"setLatestInterchainClient","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"addInterchainClient(address,bool)":{"notice":"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app."},"addTrustedModule(address)":{"notice":"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages."},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"notice":"Allows the Interchain Client to pass the message to the Interchain App."},"getAppConfigV1()":{"notice":"Returns the app config for the current app: requiredResponses and optimisticPeriod."},"getExecutionService()":{"notice":"Returns the address of the Execution Service used by this app for sending messages."},"getInterchainClients()":{"notice":"Returns the list of Interchain Clients allowed to send messages to this app."},"getLatestInterchainClient()":{"notice":"Returns the address of the latest interchain client. This address is used for sending messages from this app."},"getLinkedApp(uint256)":{"notice":"Returns the linked app address (as bytes32) for the given chain ID."},"getLinkedAppEVM(uint256)":{"notice":"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address."},"getModules()":{"notice":"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages."},"getReceivingConfig()":{"notice":"Returns the verification configuration of the Interchain App."},"linkRemoteApp(uint256,bytes32)":{"notice":"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain."},"linkRemoteAppEVM(uint256,address)":{"notice":"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter."},"removeInterchainClient(address)":{"notice":"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address."},"removeTrustedModule(address)":{"notice":"Allows the owner to remove the module from the trusted modules set."},"setAppConfigV1((uint256,uint256))":{"notice":"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final"},"setExecutionService(address)":{"notice":"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee."},"setLatestInterchainClient(address)":{"notice":"Allows the owner to set the address of the latest interchain client."}},"version":1},"developerDoc":{"kind":"dev","methods":{"addInterchainClient(address,bool)":{"params":{"client":"The address of the interchain client to add.","updateLatest":"Whether to set the latest client to this one."}},"appReceive(uint256,bytes32,uint256,uint64,bytes)":{"details":"App is responsible for keeping track of interchain clients, and must verify the message sender.","params":{"dbNonce":"The Interchain DB nonce of the batch containing the message entry.","entryIndex":"The index of the message entry within the batch.","message":"The message being sent.","sender":"Sender address on the source chain, as a bytes32 value.","srcChainId":"Chain ID of the source chain, where the message was sent from."}},"getLinkedAppEVM(uint256)":{"details":"Will revert if the linked app address is not an EVM address."},"getReceivingConfig()":{"details":"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.","returns":{"appConfig":" The versioned configuration of the Interchain App, encoded as bytes.","modules":" The list of Interchain Modules that app is trusting to confirm the messages."}},"linkRemoteApp(uint256,bytes32)":{"params":{"chainId":"The remote chain ID.","remoteApp":"The address of the remote app to link."}},"removeInterchainClient(address)":{"params":{"client":"The address of the interchain client to remove."}},"setLatestInterchainClient(address)":{"details":"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.","params":{"client":"The address of the latest interchain client."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"InterchainApp__AppZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"InterchainApp__InvalidAppConfig\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleAlreadyAdded\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"InterchainApp__ModuleNotAdded\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainApp__ModuleZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"linkedApp\",\"type\":\"bytes32\"}],\"name\":\"InterchainApp__NotEVMLinkedApp\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"updateLatest\",\"type\":\"bool\"}],\"name\":\"addInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"addTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"srcChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"appReceive\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAppConfigV1\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getExecutionService\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getInterchainClients\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getLatestInterchainClient\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedApp\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedAppEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getModules\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getReceivingConfig\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"appConfig\",\"type\":\"bytes\"},{\"internalType\":\"address[]\",\"name\":\"modules\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"linkRemoteApp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"remoteApp\",\"type\":\"address\"}],\"name\":\"linkRemoteAppEVM\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"removeInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"removeTrustedModule\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"internalType\":\"struct AppConfigV1\",\"name\":\"appConfig\",\"type\":\"tuple\"}],\"name\":\"setAppConfigV1\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"setExecutionService\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"client\",\"type\":\"address\"}],\"name\":\"setLatestInterchainClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addInterchainClient(address,bool)\":{\"params\":{\"client\":\"The address of the interchain client to add.\",\"updateLatest\":\"Whether to set the latest client to this one.\"}},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"details\":\"App is responsible for keeping track of interchain clients, and must verify the message sender.\",\"params\":{\"dbNonce\":\"The Interchain DB nonce of the batch containing the message entry.\",\"entryIndex\":\"The index of the message entry within the batch.\",\"message\":\"The message being sent.\",\"sender\":\"Sender address on the source chain, as a bytes32 value.\",\"srcChainId\":\"Chain ID of the source chain, where the message was sent from.\"}},\"getLinkedAppEVM(uint256)\":{\"details\":\"Will revert if the linked app address is not an EVM address.\"},\"getReceivingConfig()\":{\"details\":\"This configuration is used by the Interchain Client to verify that message has been confirmed by the Interchain Modules on the destination chain. Note: V1 version of AppConfig includes the required responses count, and optimistic period after which the message is considered confirmed by the module. Following versions may include additional fields.\",\"returns\":{\"appConfig\":\" The versioned configuration of the Interchain App, encoded as bytes.\",\"modules\":\" The list of Interchain Modules that app is trusting to confirm the messages.\"}},\"linkRemoteApp(uint256,bytes32)\":{\"params\":{\"chainId\":\"The remote chain ID.\",\"remoteApp\":\"The address of the remote app to link.\"}},\"removeInterchainClient(address)\":{\"params\":{\"client\":\"The address of the interchain client to remove.\"}},\"setLatestInterchainClient(address)\":{\"details\":\"The new latest client must be an allowed client or zero address. Setting the client to zero address effectively pauses the app ability to send messages, while allowing to receive them.\",\"params\":{\"client\":\"The address of the latest interchain client.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addInterchainClient(address,bool)\":{\"notice\":\"Allows the owner to add the interchain client to the allowed clients set, and optionally set the latest client to this one. Note: only the allowed clients can send messages to this app. Note: the latest client is used for sending messages from this app.\"},\"addTrustedModule(address)\":{\"notice\":\"Allows the owner to add the module to the trusted modules set. - This set of modules will be used to verify both sent and received messages.\"},\"appReceive(uint256,bytes32,uint256,uint64,bytes)\":{\"notice\":\"Allows the Interchain Client to pass the message to the Interchain App.\"},\"getAppConfigV1()\":{\"notice\":\"Returns the app config for the current app: requiredResponses and optimisticPeriod.\"},\"getExecutionService()\":{\"notice\":\"Returns the address of the Execution Service used by this app for sending messages.\"},\"getInterchainClients()\":{\"notice\":\"Returns the list of Interchain Clients allowed to send messages to this app.\"},\"getLatestInterchainClient()\":{\"notice\":\"Returns the address of the latest interchain client. This address is used for sending messages from this app.\"},\"getLinkedApp(uint256)\":{\"notice\":\"Returns the linked app address (as bytes32) for the given chain ID.\"},\"getLinkedAppEVM(uint256)\":{\"notice\":\"Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\"},\"getModules()\":{\"notice\":\"Returns the list of Interchain Modules trusted by this app. This set of modules will be used to verify both sent and received messages.\"},\"getReceivingConfig()\":{\"notice\":\"Returns the verification configuration of the Interchain App.\"},\"linkRemoteApp(uint256,bytes32)\":{\"notice\":\"Allows the owner to link the remote app for the given chain ID. - This address will be used as the receiver for the messages sent from this chain. - This address will be the only trusted sender for the messages sent to this chain.\"},\"linkRemoteAppEVM(uint256,address)\":{\"notice\":\"Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\"},\"removeInterchainClient(address)\":{\"notice\":\"Allows the owner to remove the interchain client from the allowed clients set. If the client is the latest client, the latest client is set to the zero address.\"},\"removeTrustedModule(address)\":{\"notice\":\"Allows the owner to remove the module from the trusted modules set.\"},\"setAppConfigV1((uint256,uint256))\":{\"notice\":\"Allows the owner to set the app config for the current app. App config includes: - requiredResponses: the number of module responses required for accepting the message - optimisticPeriod: the minimum time after which the module responses are considered final\"},\"setExecutionService(address)\":{\"notice\":\"Allows the owner to set the address of the Execution Service. This address will be used to request execution of the messages sent from this chain, by supplying the Service's execution fee.\"},\"setLatestInterchainClient(address)\":{\"notice\":\"Allows the owner to set the address of the latest interchain client.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IInterchainAppV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"addInterchainClient(address,bool)":"f22ba23d","addTrustedModule(address)":"cb5038fb","appReceive(uint256,bytes32,uint256,uint64,bytes)":"68a69847","getAppConfigV1()":"7717a647","getExecutionService()":"c313c807","getInterchainClients()":"a1aa5d68","getLatestInterchainClient()":"bc0d912c","getLinkedApp(uint256)":"b9b74b18","getLinkedAppEVM(uint256)":"a9ac04b6","getModules()":"b2494df3","getReceivingConfig()":"287bc057","linkRemoteApp(uint256,bytes32)":"51a30802","linkRemoteAppEVM(uint256,address)":"af8fcc8e","removeInterchainClient(address)":"0fb59156","removeTrustedModule(address)":"b70c40b3","setAppConfigV1((uint256,uint256))":"0d32b505","setExecutionService(address)":"496774b1","setLatestInterchainClient(address)":"eb53b44e"}},"solidity/ExampleAppV1.sol:IInterchainClientV1":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__FeeAmountTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__IncorrectDstChainId","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__IncorrectMsgValue","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NoLinkedClient","type":"error"},{"inputs":[{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"InterchainClientV1__NotEVMClient","type":"error"},{"inputs":[{"internalType":"uint256","name":"actual","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InterchainClientV1__NotEnoughResponses","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"InterchainClientV1__NotRemoteChainId","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxAlreadyExecuted","type":"error"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"InterchainClientV1__TxNotExecuted","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroReceiver","type":"error"},{"inputs":[],"name":"InterchainClientV1__ZeroRequiredResponses","type":"error"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"}],"name":"getExecutor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"getExecutorById","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"uint256","name":"messageLen","type":"uint256"}],"name":"getInterchainFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClient","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"getLinkedClientEVM","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"interchainExecute","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSend","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"dstChainId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"srcExecutionService","type":"address"},{"internalType":"address[]","name":"srcModules","type":"address[]"},{"internalType":"bytes","name":"options","type":"bytes"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"interchainSendEVM","outputs":[{"components":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"internalType":"struct InterchainTxDescriptor","name":"desc","type":"tuple"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"transaction","type":"bytes"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"isExecutable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"executionFees_","type":"address"}],"name":"setExecutionFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"bytes32","name":"client","type":"bytes32"}],"name":"setLinkedClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"transactionId","type":"bytes32"}],"name":"writeExecutionProof","outputs":[{"internalType":"uint256","name":"dbNonce","type":"uint256"},{"internalType":"uint64","name":"entryIndex","type":"uint64"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{"getExecutor(bytes)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getExecutorById(bytes32)":{"notice":"Returns the address of the executor for a transaction that has been sent to the local chain."},"getInterchainFee(uint256,address,address[],bytes,uint256)":{"notice":"Returns the fee for sending an Interchain message."},"getLinkedClient(uint256)":{"notice":"Returns the address of the linked client (as bytes32) for a specific chain ID."},"getLinkedClientEVM(uint256)":{"notice":"Returns the EVM address of the linked client for a specific chain ID."},"interchainExecute(uint256,bytes,bytes32[])":{"notice":"Executes a transaction that has been sent via the Interchain."},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"notice":"Sends a message to another chain via the Interchain Communication Protocol."},"isExecutable(bytes,bytes32[])":{"notice":"Checks if a transaction is executable."},"setExecutionFees(address)":{"notice":"Sets the address of the ExecutionFees contract."},"setLinkedClient(uint256,bytes32)":{"notice":"Sets the linked client for a specific chain ID."},"writeExecutionProof(bytes32)":{"notice":"Writes the proof of execution for a transaction into the InterchainDB."}},"version":1},"developerDoc":{"kind":"dev","methods":{"getInterchainFee(uint256,address,address[],bytes,uint256)":{"params":{"dstChainId":"The chain ID of the destination chain.","messageLen":"The length of the message being sent.","options":"Execution options for the message sent, currently gas limit + native gas drop.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."}},"getLinkedClient(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID."},"getLinkedClientEVM(uint256)":{"details":"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client."},"interchainExecute(uint256,bytes,bytes32[])":{"details":"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.","params":{"gasLimit":"The gas limit to use for the execution.","proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The transaction data."}},"interchainSend(uint256,bytes32,address,address[],bytes,bytes)":{"details":"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.","params":{"dstChainId":"The chain ID of the destination chain.","message":"The message being sent.","options":"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.","receiver":"The address of the receiver on the destination chain.","srcExecutionService":"The address of the execution service to use for the message.","srcModules":"The source modules involved in the message sending."},"returns":{"desc":"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch."}},"isExecutable(bytes,bytes32[])":{"details":"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules","params":{"proof":"The Merkle proof for transaction execution, fetched from the source chain.","transaction":"The InterchainTransaction struct to be checked."},"returns":{"_0":"bool Returns true if the transaction is executable, false otherwise."}},"setExecutionFees(address)":{"details":"Only callable by the contract owner or an authorized account.","params":{"executionFees_":"The address of the ExecutionFees contract."}},"setLinkedClient(uint256,bytes32)":{"details":"Stores the address of the linked client in a mapping with the chain ID as the key.","params":{"chainId":"The chain ID for which the client is being set.","client":"The address of the client being linked."}},"writeExecutionProof(bytes32)":{"details":"Will revert if the transaction has not been executed.","params":{"transactionId":"The ID of the transaction to write the proof for."},"returns":{"dbNonce":" The database nonce of the batch containing the written proof for transaction.","entryIndex":" The index of the written proof for transaction within the batch."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__FeeAmountTooLow\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectDstChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__IncorrectMsgValue\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NoLinkedClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__NotEVMClient\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"actual\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"required\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotEnoughResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"InterchainClientV1__NotRemoteChainId\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxAlreadyExecuted\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"InterchainClientV1__TxNotExecuted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroReceiver\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InterchainClientV1__ZeroRequiredResponses\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"}],\"name\":\"getExecutor\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"getExecutorById\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"messageLen\",\"type\":\"uint256\"}],\"name\":\"getInterchainFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClient\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"name\":\"getLinkedClientEVM\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"interchainExecute\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"receiver\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSend\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"dstChainId\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"srcExecutionService\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"srcModules\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"options\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"name\":\"interchainSendEVM\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"internalType\":\"struct InterchainTxDescriptor\",\"name\":\"desc\",\"type\":\"tuple\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"transaction\",\"type\":\"bytes\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"isExecutable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"executionFees_\",\"type\":\"address\"}],\"name\":\"setExecutionFees\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"client\",\"type\":\"bytes32\"}],\"name\":\"setLinkedClient\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"transactionId\",\"type\":\"bytes32\"}],\"name\":\"writeExecutionProof\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"dbNonce\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"entryIndex\",\"type\":\"uint64\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"messageLen\":\"The length of the message being sent.\",\"options\":\"Execution options for the message sent, currently gas limit + native gas drop.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"}},\"getLinkedClient(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"details\":\"Will return 0x0 if no client is linked for the chain ID. Will revert if the client is not an EVM client.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"details\":\"The transaction must have been previously sent and recorded. Transaction data includes the requested gas limit, but the executors could specify a different gas limit. If the specified gas limit is lower than requested, the requested gas limit will be used. Otherwise, the specified gas limit will be used. This allows to execute the transactions with requested gas limit set too low.\",\"params\":{\"gasLimit\":\"The gas limit to use for the execution.\",\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The transaction data.\"}},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"details\":\"Charges a fee for the message, which is payable upon calling this function: - Verification fees: paid to every module that verifies the message. - Execution fee: paid to the executor that executes the message. Note: while a specific execution service is specified to request the execution of the message, any executor is able to execute the message on destination chain, earning the execution fee.\",\"params\":{\"dstChainId\":\"The chain ID of the destination chain.\",\"message\":\"The message being sent.\",\"options\":\"Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\",\"receiver\":\"The address of the receiver on the destination chain.\",\"srcExecutionService\":\"The address of the execution service to use for the message.\",\"srcModules\":\"The source modules involved in the message sending.\"},\"returns\":{\"desc\":\"The descriptor of the sent transaction: - transactionId: the ID of the transaction that was sent. - dbNonce: the database nonce of the batch containing the written entry for transaction. - entryIndex: the index of the written entry for transaction within the batch.\"}},\"isExecutable(bytes,bytes32[])\":{\"details\":\"Determines if a transaction meets the criteria to be executed based on: - If approved modules have written to the InterchainDB - If the threshold of approved modules have been met - If the optimistic window has passed for all modules\",\"params\":{\"proof\":\"The Merkle proof for transaction execution, fetched from the source chain.\",\"transaction\":\"The InterchainTransaction struct to be checked.\"},\"returns\":{\"_0\":\"bool Returns true if the transaction is executable, false otherwise.\"}},\"setExecutionFees(address)\":{\"details\":\"Only callable by the contract owner or an authorized account.\",\"params\":{\"executionFees_\":\"The address of the ExecutionFees contract.\"}},\"setLinkedClient(uint256,bytes32)\":{\"details\":\"Stores the address of the linked client in a mapping with the chain ID as the key.\",\"params\":{\"chainId\":\"The chain ID for which the client is being set.\",\"client\":\"The address of the client being linked.\"}},\"writeExecutionProof(bytes32)\":{\"details\":\"Will revert if the transaction has not been executed.\",\"params\":{\"transactionId\":\"The ID of the transaction to write the proof for.\"},\"returns\":{\"dbNonce\":\" The database nonce of the batch containing the written proof for transaction.\",\"entryIndex\":\" The index of the written proof for transaction within the batch.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"getExecutor(bytes)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getExecutorById(bytes32)\":{\"notice\":\"Returns the address of the executor for a transaction that has been sent to the local chain.\"},\"getInterchainFee(uint256,address,address[],bytes,uint256)\":{\"notice\":\"Returns the fee for sending an Interchain message.\"},\"getLinkedClient(uint256)\":{\"notice\":\"Returns the address of the linked client (as bytes32) for a specific chain ID.\"},\"getLinkedClientEVM(uint256)\":{\"notice\":\"Returns the EVM address of the linked client for a specific chain ID.\"},\"interchainExecute(uint256,bytes,bytes32[])\":{\"notice\":\"Executes a transaction that has been sent via the Interchain.\"},\"interchainSend(uint256,bytes32,address,address[],bytes,bytes)\":{\"notice\":\"Sends a message to another chain via the Interchain Communication Protocol.\"},\"isExecutable(bytes,bytes32[])\":{\"notice\":\"Checks if a transaction is executable.\"},\"setExecutionFees(address)\":{\"notice\":\"Sets the address of the ExecutionFees contract.\"},\"setLinkedClient(uint256,bytes32)\":{\"notice\":\"Sets the linked client for a specific chain ID.\"},\"writeExecutionProof(bytes32)\":{\"notice\":\"Writes the proof of execution for a transaction into the InterchainDB.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"IInterchainClientV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{"getExecutor(bytes)":"f92a79ff","getExecutorById(bytes32)":"f1a61fac","getInterchainFee(uint256,address,address[],bytes,uint256)":"7a1277db","getLinkedClient(uint256)":"aa102ec4","getLinkedClientEVM(uint256)":"02172a35","interchainExecute(uint256,bytes,bytes32[])":"53b67d74","interchainSend(uint256,bytes32,address,address[],bytes,bytes)":"98939d28","interchainSendEVM(uint256,address,address,address[],bytes,bytes)":"827f940d","isExecutable(bytes,bytes32[])":"1450c281","setExecutionFees(address)":"3dc68b87","setLinkedClient(uint256,bytes32)":"f34234c8","writeExecutionProof(bytes32)":"90e81077"}},"solidity/ExampleAppV1.sol:InterchainAppV1Events":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"requiredResponses","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"optimisticPeriod","type":"uint256"}],"name":"AppConfigV1Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"chainId","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"remoteApp","type":"bytes32"}],"name":"AppLinked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executionService","type":"address"}],"name":"ExecutionServiceSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"module","type":"address"}],"name":"TrustedModuleRemoved","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"requiredResponses\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticPeriod\",\"type\":\"uint256\"}],\"name\":\"AppConfigV1Set\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"remoteApp\",\"type\":\"bytes32\"}],\"name\":\"AppLinked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"executionService\",\"type\":\"address\"}],\"name\":\"ExecutionServiceSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"module\",\"type\":\"address\"}],\"name\":\"TrustedModuleRemoved\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"InterchainAppV1Events\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:InterchainTransactionLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220accceebe9679b3ac91ab2de0807ed97aa77b6c6556c8e5b5929ea06f1c37c75a64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220accceebe9679b3ac91ab2de0807ed97aa77b6c6556c8e5b5929ea06f1c37c75a64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"37187:1773:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;37187:1773:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"37187:1773:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"InterchainTransactionLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:MathLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f957455d0e937771907f72d1079f7de532fee96656aff32d2c15ec9aa8c996a964736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f957455d0e937771907f72d1079f7de532fee96656aff32d2c15ec9aa8c996a964736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"2472:403:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;2472:403:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"2472:403:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"MathLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207d869ce787cbbb5212c74841e7164c6ad54b17e4cec09637745dd8901a6d279964736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212207d869ce787cbbb5212c74841e7164c6ad54b17e4cec09637745dd8901a6d279964736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"33383:1233:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;33383:1233:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"33383:1233:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:TypeCasts":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f979f496a09f113b5f662c0f5c4d4aff1d533844c8e5cabf35cbd41980c56db264736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220f979f496a09f113b5f662c0f5c4d4aff1d533844c8e5cabf35cbd41980c56db264736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"2910:280:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;2910:280:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"2910:280:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"TypeCasts\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}},"solidity/ExampleAppV1.sol:VersionedPayloadLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122000d9abcc4f15b9b07c85217b76ddf623350b0b562e782f8870d2001634c9838f64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122000d9abcc4f15b9b07c85217b76ddf623350b0b562e782f8870d2001634c9838f64736f6c63430008140033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity =0.8.20 ^0.8.0 ^0.8.13 ^0.8.20;\n\n// contracts/events/AbstractICAppEvents.sol\n\nabstract contract AbstractICAppEvents {\n event InterchainClientAdded(address client);\n event InterchainClientRemoved(address client);\n event LatestClientSet(address client);\n}\n\n// contracts/events/InterchainAppV1Events.sol\n\nabstract contract InterchainAppV1Events {\n event AppConfigV1Set(uint256 requiredResponses, uint256 optimisticPeriod);\n event AppLinked(uint256 indexed chainId, bytes32 indexed remoteApp);\n event ExecutionServiceSet(address executionService);\n event TrustedModuleAdded(address module);\n event TrustedModuleRemoved(address module);\n}\n\n// contracts/interfaces/IInterchainApp.sol\n\n/// @notice Minimal interface for the Interchain App to work with the Interchain Client.\ninterface IInterchainApp {\n /// @notice Allows the Interchain Client to pass the message to the Interchain App.\n /// @dev App is responsible for keeping track of interchain clients, and must verify the message sender.\n /// @param srcChainId Chain ID of the source chain, where the message was sent from.\n /// @param sender Sender address on the source chain, as a bytes32 value.\n /// @param dbNonce The Interchain DB nonce of the batch containing the message entry.\n /// @param entryIndex The index of the message entry within the batch.\n /// @param message The message being sent.\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable;\n\n /// @notice Returns the verification configuration of the Interchain App.\n /// @dev This configuration is used by the Interchain Client to verify that message has been confirmed\n /// by the Interchain Modules on the destination chain.\n /// Note: V1 version of AppConfig includes the required responses count, and optimistic period after which\n /// the message is considered confirmed by the module. Following versions may include additional fields.\n /// @return appConfig The versioned configuration of the Interchain App, encoded as bytes.\n /// @return modules The list of Interchain Modules that app is trusting to confirm the messages.\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules);\n}\n\n// contracts/libs/Math.sol\n\nlibrary MathLib {\n /// @notice Rounds up to the nearest multiple of 32.\n /// Note: Returns zero on overflows instead of reverting. This is fine for practical\n /// use cases, as this is used for determining the size of the payload in memory.\n function roundUpToWord(uint256 x) internal pure returns (uint256) {\n unchecked {\n return (x + 31) \u0026 ~uint256(31);\n }\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/IAccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev The `account` is missing a role.\n */\n error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\n\n /**\n * @dev The caller of a function is not the expected one.\n *\n * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\n */\n error AccessControlBadConfirmation();\n\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n */\n function renounceRole(bytes32 role, address callerConfirmation) external;\n}\n\n// node_modules/@openzeppelin/contracts/utils/Address.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance \u003c amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance \u003c value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 \u0026\u0026 target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/Context.sol\n\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/utils/structs/EnumerableSet.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position is the index of the value in the `values` array plus 1.\n // Position 0 is used to mean a value is not in the set.\n mapping(bytes32 value =\u003e uint256) _positions;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._positions[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We cache the value's position to prevent multiple reads from the same storage slot\n uint256 position = set._positions[value];\n\n if (position != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 valueIndex = position - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (valueIndex != lastIndex) {\n bytes32 lastValue = set._values[lastIndex];\n\n // Move the lastValue to the index where the value to delete is\n set._values[valueIndex] = lastValue;\n // Update the tracked position of the lastValue (that was just moved)\n set._positions[lastValue] = position;\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the tracked position for the deleted slot\n delete set._positions[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._positions[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n bytes32[] memory store = _values(set._inner);\n bytes32[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n /// @solidity memory-safe-assembly\n assembly {\n result := store\n }\n\n return result;\n }\n}\n\n// contracts/libs/AppConfig.sol\n\nstruct AppConfigV1 {\n uint256 requiredResponses;\n uint256 optimisticPeriod;\n}\n\nusing AppConfigLib for AppConfigV1 global;\n\nlibrary AppConfigLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant APP_CONFIG_V1 = 1;\n\n error AppConfigLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes app config (V1 or higher) from a bytes format back into an AppConfigV1 struct.\n /// @param data The app config data in bytes format.\n function decodeAppConfigV1(bytes memory data) internal view returns (AppConfigV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c APP_CONFIG_V1) {\n revert AppConfigLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (AppConfigV1));\n }\n\n /// @notice Encodes V1 app config into a bytes format.\n /// @param appConfig The AppConfigV1 to encode.\n function encodeAppConfigV1(AppConfigV1 memory appConfig) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(APP_CONFIG_V1, abi.encode(appConfig));\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n\n// node_modules/@openzeppelin/contracts/utils/introspection/ERC165.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n\n// contracts/libs/InterchainTransaction.sol\n\nstruct InterchainTransaction {\n uint256 srcChainId;\n bytes32 srcSender;\n uint256 dstChainId;\n bytes32 dstReceiver;\n uint256 dbNonce;\n uint64 entryIndex;\n bytes options;\n bytes message;\n}\n\nstruct InterchainTxDescriptor {\n bytes32 transactionId;\n uint256 dbNonce;\n uint64 entryIndex;\n}\n\nusing InterchainTransactionLib for InterchainTransaction global;\n\nlibrary InterchainTransactionLib {\n using MathLib for uint256;\n\n function constructLocalTransaction(\n address srcSender,\n uint256 dstChainId,\n bytes32 dstReceiver,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes memory options,\n bytes memory message\n )\n internal\n view\n returns (InterchainTransaction memory transaction)\n {\n return InterchainTransaction({\n srcChainId: block.chainid,\n srcSender: TypeCasts.addressToBytes32(srcSender),\n dstChainId: dstChainId,\n dstReceiver: dstReceiver,\n dbNonce: dbNonce,\n entryIndex: entryIndex,\n options: options,\n message: message\n });\n }\n\n function encodeTransaction(InterchainTransaction memory transaction) internal pure returns (bytes memory) {\n return abi.encode(transaction);\n }\n\n function decodeTransaction(bytes memory encodedTx) internal pure returns (InterchainTransaction memory) {\n return abi.decode(encodedTx, (InterchainTransaction));\n }\n\n function payloadSize(uint256 optionsLen, uint256 messageLen) internal pure returns (uint256) {\n // 8 fields * 32 bytes (6 values for static, 2 offsets for dynamic) + 2 * 32 bytes (lengths for dynamic) = 320\n // abi.encode() also prepends the global offset (which is always 0x20) if there's a dynamic field, making it 352\n // Both options and message are dynamic fields, which are padded up to 32 bytes\n return 352 + optionsLen.roundUpToWord() + messageLen.roundUpToWord();\n }\n\n function transactionId(InterchainTransaction memory transaction) internal pure returns (bytes32) {\n return keccak256(abi.encode(transaction));\n }\n}\n\n// contracts/interfaces/IInterchainAppV1.sol\n\ninterface IInterchainAppV1 is IInterchainApp {\n error InterchainApp__AppZeroAddress();\n error InterchainApp__InvalidAppConfig(uint256 requiredResponses, uint256 optimisticPeriod);\n error InterchainApp__ModuleAlreadyAdded(address module);\n error InterchainApp__ModuleNotAdded(address module);\n error InterchainApp__ModuleZeroAddress();\n error InterchainApp__NotEVMLinkedApp(bytes32 linkedApp);\n\n /// @notice Allows the owner to add the interchain client to the allowed clients set,\n /// and optionally set the latest client to this one.\n /// Note: only the allowed clients can send messages to this app.\n /// Note: the latest client is used for sending messages from this app.\n /// @param client The address of the interchain client to add.\n /// @param updateLatest Whether to set the latest client to this one.\n function addInterchainClient(address client, bool updateLatest) external;\n\n /// @notice Allows the owner to remove the interchain client from the allowed clients set.\n /// If the client is the latest client, the latest client is set to the zero address.\n /// @param client The address of the interchain client to remove.\n function removeInterchainClient(address client) external;\n\n /// @notice Allows the owner to set the address of the latest interchain client.\n /// @dev The new latest client must be an allowed client or zero address.\n /// Setting the client to zero address effectively pauses the app ability to send messages,\n /// while allowing to receive them.\n /// @param client The address of the latest interchain client.\n function setLatestInterchainClient(address client) external;\n\n /// @notice Allows the owner to link the remote app for the given chain ID.\n /// - This address will be used as the receiver for the messages sent from this chain.\n /// - This address will be the only trusted sender for the messages sent to this chain.\n /// @param chainId The remote chain ID.\n /// @param remoteApp The address of the remote app to link.\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external;\n\n /// @notice Thin wrapper for `linkRemoteApp` to accept EVM address as a parameter.\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external;\n\n /// @notice Allows the owner to add the module to the trusted modules set.\n /// - This set of modules will be used to verify both sent and received messages.\n function addTrustedModule(address module) external;\n\n /// @notice Allows the owner to remove the module from the trusted modules set.\n function removeTrustedModule(address module) external;\n\n /// @notice Allows the owner to set the app config for the current app. App config includes:\n /// - requiredResponses: the number of module responses required for accepting the message\n /// - optimisticPeriod: the minimum time after which the module responses are considered final\n function setAppConfigV1(AppConfigV1 memory appConfig) external;\n\n /// @notice Allows the owner to set the address of the Execution Service.\n /// This address will be used to request execution of the messages sent from this chain,\n /// by supplying the Service's execution fee.\n function setExecutionService(address executionService) external;\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @notice Returns the app config for the current app: requiredResponses and optimisticPeriod.\n function getAppConfigV1() external view returns (AppConfigV1 memory);\n\n /// @notice Returns the address of the Execution Service used by this app for sending messages.\n function getExecutionService() external view returns (address);\n\n /// @notice Returns the list of Interchain Clients allowed to send messages to this app.\n function getInterchainClients() external view returns (address[] memory);\n\n /// @notice Returns the address of the latest interchain client.\n /// This address is used for sending messages from this app.\n function getLatestInterchainClient() external view returns (address);\n\n /// @notice Returns the linked app address (as bytes32) for the given chain ID.\n function getLinkedApp(uint256 chainId) external view returns (bytes32);\n\n /// @notice Thin wrapper for `getLinkedApp` to return the linked app address as EVM address.\n /// @dev Will revert if the linked app address is not an EVM address.\n function getLinkedAppEVM(uint256 chainId) external view returns (address);\n\n /// @notice Returns the list of Interchain Modules trusted by this app.\n /// This set of modules will be used to verify both sent and received messages.\n function getModules() external view returns (address[] memory);\n}\n\n// contracts/interfaces/IInterchainClientV1.sol\n\ninterface IInterchainClientV1 {\n error InterchainClientV1__FeeAmountTooLow(uint256 actual, uint256 required);\n error InterchainClientV1__IncorrectDstChainId(uint256 chainId);\n error InterchainClientV1__IncorrectMsgValue(uint256 actual, uint256 required);\n error InterchainClientV1__NoLinkedClient(uint256 chainId);\n error InterchainClientV1__NotEnoughResponses(uint256 actual, uint256 required);\n error InterchainClientV1__NotEVMClient(bytes32 client);\n error InterchainClientV1__NotRemoteChainId(uint256 chainId);\n error InterchainClientV1__TxAlreadyExecuted(bytes32 transactionId);\n error InterchainClientV1__TxNotExecuted(bytes32 transactionId);\n error InterchainClientV1__ZeroReceiver();\n error InterchainClientV1__ZeroRequiredResponses();\n\n /**\n * @notice Sets the address of the ExecutionFees contract.\n * @dev Only callable by the contract owner or an authorized account.\n * @param executionFees_ The address of the ExecutionFees contract.\n */\n function setExecutionFees(address executionFees_) external;\n\n /**\n * @notice Sets the linked client for a specific chain ID.\n * @dev Stores the address of the linked client in a mapping with the chain ID as the key.\n * @param chainId The chain ID for which the client is being set.\n * @param client The address of the client being linked.\n */\n function setLinkedClient(uint256 chainId, bytes32 client) external;\n\n /**\n * @notice Sends a message to another chain via the Interchain Communication Protocol.\n * @dev Charges a fee for the message, which is payable upon calling this function:\n * - Verification fees: paid to every module that verifies the message.\n * - Execution fee: paid to the executor that executes the message.\n * Note: while a specific execution service is specified to request the execution of the message,\n * any executor is able to execute the message on destination chain, earning the execution fee.\n * @param dstChainId The chain ID of the destination chain.\n * @param receiver The address of the receiver on the destination chain.\n * @param srcExecutionService The address of the execution service to use for the message.\n * @param srcModules The source modules involved in the message sending.\n * @param options Execution options for the message sent, encoded as bytes, currently gas limit + native gas drop.\n * @param message The message being sent.\n * @return desc The descriptor of the sent transaction:\n * - transactionId: the ID of the transaction that was sent.\n * - dbNonce: the database nonce of the batch containing the written entry for transaction.\n * - entryIndex: the index of the written entry for transaction within the batch.\n */\n function interchainSend(\n uint256 dstChainId,\n bytes32 receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n function interchainSendEVM(\n uint256 dstChainId,\n address receiver,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n bytes calldata message\n )\n external\n payable\n returns (InterchainTxDescriptor memory desc);\n\n /**\n * @notice Executes a transaction that has been sent via the Interchain.\n * @dev The transaction must have been previously sent and recorded.\n * Transaction data includes the requested gas limit, but the executors could specify a different gas limit.\n * If the specified gas limit is lower than requested, the requested gas limit will be used.\n * Otherwise, the specified gas limit will be used.\n * This allows to execute the transactions with requested gas limit set too low.\n * @param gasLimit The gas limit to use for the execution.\n * @param transaction The transaction data.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n */\n function interchainExecute(\n uint256 gasLimit,\n bytes calldata transaction,\n bytes32[] calldata proof\n )\n external\n payable;\n\n /// @notice Writes the proof of execution for a transaction into the InterchainDB.\n /// @dev Will revert if the transaction has not been executed.\n /// @param transactionId The ID of the transaction to write the proof for.\n /// @return dbNonce The database nonce of the batch containing the written proof for transaction.\n /// @return entryIndex The index of the written proof for transaction within the batch.\n function writeExecutionProof(bytes32 transactionId) external returns (uint256 dbNonce, uint64 entryIndex);\n\n /**\n * @notice Checks if a transaction is executable.\n * @dev Determines if a transaction meets the criteria to be executed based on:\n * - If approved modules have written to the InterchainDB\n * - If the threshold of approved modules have been met\n * - If the optimistic window has passed for all modules\n * @param transaction The InterchainTransaction struct to be checked.\n * @param proof The Merkle proof for transaction execution, fetched from the source chain.\n * @return bool Returns true if the transaction is executable, false otherwise.\n */\n function isExecutable(bytes calldata transaction, bytes32[] calldata proof) external view returns (bool);\n\n /// @notice Returns the fee for sending an Interchain message.\n /// @param dstChainId The chain ID of the destination chain.\n /// @param srcExecutionService The address of the execution service to use for the message.\n /// @param srcModules The source modules involved in the message sending.\n /// @param options Execution options for the message sent, currently gas limit + native gas drop.\n /// @param messageLen The length of the message being sent.\n function getInterchainFee(\n uint256 dstChainId,\n address srcExecutionService,\n address[] calldata srcModules,\n bytes calldata options,\n uint256 messageLen\n )\n external\n view\n returns (uint256);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutor(bytes calldata transaction) external view returns (address);\n\n /// @notice Returns the address of the executor for a transaction that has been sent to the local chain.\n function getExecutorById(bytes32 transactionId) external view returns (address);\n\n /// @notice Returns the address of the linked client (as bytes32) for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n function getLinkedClient(uint256 chainId) external view returns (bytes32);\n\n /// @notice Returns the EVM address of the linked client for a specific chain ID.\n /// @dev Will return 0x0 if no client is linked for the chain ID.\n /// Will revert if the client is not an EVM client.\n function getLinkedClientEVM(uint256 chainId) external view returns (address);\n}\n\n// node_modules/@openzeppelin/contracts/access/AccessControl.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address account =\u003e bool) hasRole;\n bytes32 adminRole;\n }\n\n mapping(bytes32 role =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with an {AccessControlUnauthorizedAccount} error including the required role.\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role);\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual returns (bool) {\n return _roles[role].hasRole[account];\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\n * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\n */\n function _checkRole(bytes32 role) internal view virtual {\n _checkRole(role, _msgSender());\n }\n\n /**\n * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\n * is missing `role`.\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert AccessControlUnauthorizedAccount(account, role);\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleGranted} event.\n */\n function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n *\n * May emit a {RoleRevoked} event.\n */\n function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `callerConfirmation`.\n *\n * May emit a {RoleRevoked} event.\n */\n function renounceRole(bytes32 role, address callerConfirmation) public virtual {\n if (callerConfirmation != _msgSender()) {\n revert AccessControlBadConfirmation();\n }\n\n _revokeRole(role, callerConfirmation);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleGranted} event.\n */\n function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\n if (!hasRole(role, account)) {\n _roles[role].hasRole[account] = true;\n emit RoleGranted(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.\n *\n * Internal function without access restriction.\n *\n * May emit a {RoleRevoked} event.\n */\n function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\n if (hasRole(role, account)) {\n _roles[role].hasRole[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n return true;\n } else {\n return false;\n }\n }\n}\n\n// contracts/apps/AbstractICApp.sol\n\nabstract contract AbstractICApp is AbstractICAppEvents, IInterchainApp {\n using TypeCasts for address;\n\n error InterchainApp__AlreadyLatestClient(address client);\n error InterchainApp__BalanceTooLow(uint256 actual, uint256 required);\n error InterchainApp__ClientAlreadyAdded(address client);\n error InterchainApp__InterchainClientZeroAddress();\n error InterchainApp__NotInterchainClient(address account);\n error InterchainApp__ReceiverNotSet(uint256 chainId);\n error InterchainApp__SameChainId(uint256 chainId);\n error InterchainApp__SenderNotAllowed(uint256 srcChainId, bytes32 sender);\n\n /// @inheritdoc IInterchainApp\n function appReceive(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n external\n payable\n {\n if (!_isInterchainClient(msg.sender)) {\n revert InterchainApp__NotInterchainClient(msg.sender);\n }\n if (srcChainId == block.chainid) {\n revert InterchainApp__SameChainId(srcChainId);\n }\n if (!_isAllowedSender(srcChainId, sender)) {\n revert InterchainApp__SenderNotAllowed(srcChainId, sender);\n }\n _receiveMessage(srcChainId, sender, dbNonce, entryIndex, message);\n }\n\n /// @inheritdoc IInterchainApp\n function getReceivingConfig() external view returns (bytes memory appConfig, address[] memory modules) {\n appConfig = _getAppConfig();\n modules = _getModules();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Performs necessary checks and adds an Interchain Client.\n /// Optionally sets the latest client to this one.\n /// Note: should be guarded with permission checks in the derived contracts.\n function _addClient(address client, bool updateLatest) internal {\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (_isInterchainClient(client)) {\n revert InterchainApp__ClientAlreadyAdded(client);\n }\n _toggleClientState(client, true);\n emit InterchainClientAdded(client);\n if (updateLatest) {\n _setLatestClient(client);\n }\n }\n\n /// @dev Performs necessary checks and removes an Interchain Client. If this client is the latest one,\n /// the latest client is set to zero address (effectively pausing the app ability to send messages).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _removeClient(address client) internal {\n if (!_isInterchainClient(client)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n _toggleClientState(client, false);\n emit InterchainClientRemoved(client);\n if (client == _getLatestClient()) {\n _setLatestClient(address(0));\n }\n }\n\n /// @dev Sets the latest Interchain Client to one of the allowed clients. Setting the client to zero address\n /// is allowed and effectively pauses the app ability to send messages (but still allows to receive them).\n /// Note: should be guarded with permission checks in the derived contracts.\n function _setLatestClient(address client) internal {\n // New latest client must be an allowed client or zero address.\n if (!_isInterchainClient(client) \u0026\u0026 client != address(0)) {\n revert InterchainApp__NotInterchainClient(client);\n }\n if (client == _getLatestClient()) {\n revert InterchainApp__AlreadyLatestClient(client);\n }\n _storeLatestClient(client);\n emit LatestClientSet(client);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal virtual;\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal virtual;\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to accept EVM address as a parameter.\n function _sendInterchainMessageEVM(\n uint256 dstChainId,\n address receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n return _sendInterchainMessage(dstChainId, receiver.addressToBytes32(), messageFee, options, message);\n }\n\n /// @dev Performs necessary checks and sends an interchain message.\n function _sendInterchainMessage(\n uint256 dstChainId,\n bytes32 receiver,\n uint256 messageFee,\n bytes memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory desc)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n if (dstChainId == block.chainid) {\n revert InterchainApp__SameChainId(dstChainId);\n }\n if (receiver == 0) {\n revert InterchainApp__ReceiverNotSet(dstChainId);\n }\n if (address(this).balance \u003c messageFee) {\n revert InterchainApp__BalanceTooLow({actual: address(this).balance, required: messageFee});\n }\n return IInterchainClientV1(client).interchainSend{value: messageFee}(\n dstChainId, receiver, _getExecutionService(), _getModules(), options, message\n );\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n virtual;\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee for sending an Interchain message.\n function _getInterchainFee(\n uint256 dstChainId,\n bytes memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n address client = _getLatestClient();\n if (client == address(0)) {\n revert InterchainApp__InterchainClientZeroAddress();\n }\n return IInterchainClientV1(client).getInterchainFee(\n dstChainId, _getExecutionService(), _getModules(), options, messageLen\n );\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view virtual returns (bytes memory);\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view virtual returns (address);\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view virtual returns (address);\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view virtual returns (address[] memory);\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view virtual returns (bool);\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view virtual returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol\n\n// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 role =\u003e EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {AccessControl-_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool granted = super._grantRole(role, account);\n if (granted) {\n _roleMembers[role].add(account);\n }\n return granted;\n }\n\n /**\n * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {\n bool revoked = super._revokeRole(role, account);\n if (revoked) {\n _roleMembers[role].remove(account);\n }\n return revoked;\n }\n}\n\n// contracts/apps/ICAppV1.sol\n\nabstract contract ICAppV1 is AbstractICApp, AccessControlEnumerable, InterchainAppV1Events, IInterchainAppV1 {\n using EnumerableSet for EnumerableSet.AddressSet;\n using TypeCasts for address;\n using TypeCasts for bytes32;\n\n /// @notice Role to manage the Interchain setup of the app.\n bytes32 public constant IC_GOVERNOR_ROLE = keccak256(\"IC_GOVERNOR_ROLE\");\n\n /// @dev Address of the latest Interchain Client, used for sending messages.\n address private _latestClient;\n\n /// @dev Required responses and optimistic period for the module responses.\n AppConfigV1 private _appConfigV1;\n /// @dev Address of the linked app deployed on the remote chain.\n mapping(uint256 chainId =\u003e bytes32 remoteApp) private _linkedApp;\n /// @dev Interchain Clients allowed to send messages to this app.\n EnumerableSet.AddressSet private _interchainClients;\n /// @dev Trusted Interchain modules.\n EnumerableSet.AddressSet private _trustedModules;\n /// @dev Execution Service to use for sending messages.\n address private _executionService;\n\n constructor(address admin) {\n _grantRole(DEFAULT_ADMIN_ROLE, admin);\n }\n\n /// @inheritdoc IInterchainAppV1\n function addInterchainClient(address client, bool updateLatest) external onlyRole(IC_GOVERNOR_ROLE) {\n _addClient(client, updateLatest);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _removeClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setLatestInterchainClient(address client) external onlyRole(IC_GOVERNOR_ROLE) {\n _setLatestClient(client);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteApp(uint256 chainId, bytes32 remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp);\n }\n\n /// @inheritdoc IInterchainAppV1\n function linkRemoteAppEVM(uint256 chainId, address remoteApp) external onlyRole(IC_GOVERNOR_ROLE) {\n _linkRemoteApp(chainId, remoteApp.addressToBytes32());\n }\n\n /// @inheritdoc IInterchainAppV1\n function addTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n if (module == address(0)) {\n revert InterchainApp__ModuleZeroAddress();\n }\n bool added = _trustedModules.add(module);\n if (!added) {\n revert InterchainApp__ModuleAlreadyAdded(module);\n }\n emit TrustedModuleAdded(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function removeTrustedModule(address module) external onlyRole(IC_GOVERNOR_ROLE) {\n bool removed = _trustedModules.remove(module);\n if (!removed) {\n revert InterchainApp__ModuleNotAdded(module);\n }\n emit TrustedModuleRemoved(module);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setAppConfigV1(AppConfigV1 memory appConfig) external onlyRole(IC_GOVERNOR_ROLE) {\n if (appConfig.requiredResponses == 0 || appConfig.optimisticPeriod == 0) {\n revert InterchainApp__InvalidAppConfig(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n _appConfigV1 = appConfig;\n emit AppConfigV1Set(appConfig.requiredResponses, appConfig.optimisticPeriod);\n }\n\n /// @inheritdoc IInterchainAppV1\n function setExecutionService(address executionService) external onlyRole(IC_GOVERNOR_ROLE) {\n _executionService = executionService;\n emit ExecutionServiceSet(executionService);\n }\n\n // ═══════════════════════════════════════════════════ VIEWS ═══════════════════════════════════════════════════════\n\n /// @inheritdoc IInterchainAppV1\n function getAppConfigV1() external view returns (AppConfigV1 memory) {\n return _appConfigV1;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getExecutionService() external view returns (address) {\n return _executionService;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getInterchainClients() external view returns (address[] memory) {\n return _interchainClients.values();\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLatestInterchainClient() external view returns (address) {\n return _latestClient;\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedApp(uint256 chainId) external view returns (bytes32) {\n return _linkedApp[chainId];\n }\n\n /// @inheritdoc IInterchainAppV1\n function getLinkedAppEVM(uint256 chainId) external view returns (address linkedAppEVM) {\n bytes32 linkedApp = _linkedApp[chainId];\n linkedAppEVM = linkedApp.bytes32ToAddress();\n if (linkedAppEVM.addressToBytes32() != linkedApp) {\n revert InterchainApp__NotEVMLinkedApp(linkedApp);\n }\n }\n\n /// @inheritdoc IInterchainAppV1\n function getModules() external view returns (address[] memory) {\n return _trustedModules.values();\n }\n\n // ═══════════════════════════════════════════ INTERNAL: MANAGEMENT ════════════════════════════════════════════════\n\n /// @dev Links the remote app to the current app.\n /// Will revert if the chainId is the same as the chainId of the local app.\n /// Note: Should be guarded with permissions check.\n function _linkRemoteApp(uint256 chainId, bytes32 remoteApp) internal {\n if (chainId == block.chainid) {\n revert InterchainApp__SameChainId(chainId);\n }\n if (remoteApp == 0) {\n revert InterchainApp__AppZeroAddress();\n }\n _linkedApp[chainId] = remoteApp;\n emit AppLinked(chainId, remoteApp);\n }\n\n /// @dev Stores the address of the latest Interchain Client.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_setLatestClient` instead.\n /// - Should not emit any events: this is done in the calling function.\n function _storeLatestClient(address client) internal override {\n _latestClient = client;\n }\n\n /// @dev Toggle the state of the Interchain Client (allowed/disallowed to send messages to this app).\n /// - The client is checked to be in the opposite state before the change.\n /// - The exact storage location is up to the implementation.\n /// - Must NOT be called directly: use `_addClient` and `_removeClient` instead.\n /// - Should not emit any events: this is done in the calling functions.\n function _toggleClientState(address client, bool allowed) internal override {\n if (allowed) {\n _interchainClients.add(client);\n } else {\n _interchainClients.remove(client);\n }\n }\n\n // ════════════════════════════════════════════ INTERNAL: MESSAGING ════════════════════════════════════════════════\n\n /// @dev Thin wrapper around _sendInterchainMessage to send the message to the linked app.\n function _sendToLinkedApp(\n uint256 dstChainId,\n uint256 messageFee,\n OptionsV1 memory options,\n bytes memory message\n )\n internal\n returns (InterchainTxDescriptor memory)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _sendInterchainMessage(dstChainId, _linkedApp[dstChainId], messageFee, encodedOptions, message);\n }\n\n // ══════════════════════════════════════════════ INTERNAL VIEWS ═══════════════════════════════════════════════════\n\n /// @dev Returns the fee to send a message to the linked app on the remote chain.\n function _getMessageFee(\n uint256 dstChainId,\n OptionsV1 memory options,\n uint256 messageLen\n )\n internal\n view\n returns (uint256)\n {\n bytes memory encodedOptions = options.encodeOptionsV1();\n return _getInterchainFee(dstChainId, encodedOptions, messageLen);\n }\n\n /// @dev Returns the configuration of the app for validating the received messages.\n function _getAppConfig() internal view override returns (bytes memory) {\n return _appConfigV1.encodeAppConfigV1();\n }\n\n /// @dev Returns the address of the Execution Service to use for sending messages.\n function _getExecutionService() internal view override returns (address) {\n return _executionService;\n }\n\n /// @dev Returns the latest Interchain Client. This is the Client that is used for sending messages.\n function _getLatestClient() internal view override returns (address) {\n return _latestClient;\n }\n\n /// @dev Returns the list of modules to use for sending messages, as well as validating the received messages.\n function _getModules() internal view override returns (address[] memory) {\n return _trustedModules.values();\n }\n\n /// @dev Checks if the sender is allowed to send messages to this app.\n function _isAllowedSender(uint256 srcChainId, bytes32 sender) internal view override returns (bool) {\n return _linkedApp[srcChainId] == sender;\n }\n\n /// @dev Checks if the caller is an Interchain Client.\n /// Both latest and legacy Interchain Clients are allowed to call `appReceive`.\n function _isInterchainClient(address caller) internal view override returns (bool) {\n return _interchainClients.contains(caller);\n }\n}\n\n// contracts/apps/examples/ExampleAppV1.sol\n\ncontract ExampleAppV1 is ICAppV1 {\n event MessageReceived(uint256 srcChainId, bytes32 sender, uint256 dbNonce, uint64 entryIndex, bytes message);\n event MessageSent(uint256 dstChainId, uint256 dbNonce, uint64 entryIndex, bytes32 transactionId);\n\n constructor(address admin) ICAppV1(admin) {\n _grantRole(IC_GOVERNOR_ROLE, admin);\n }\n\n /// @notice Allows the Admin to withdraw the native asset from the contract.\n function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {\n Address.sendValue(payable(msg.sender), address(this).balance);\n }\n\n /// @notice Sends a basic message to the destination chain.\n function sendMessage(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes calldata message\n )\n external\n payable\n {\n InterchainTxDescriptor memory desc = _sendToLinkedApp({\n dstChainId: dstChainId,\n messageFee: msg.value,\n options: OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}),\n message: message\n });\n emit MessageSent(dstChainId, desc.dbNonce, desc.entryIndex, desc.transactionId);\n }\n\n /// @notice Returns the fee required to send a message using `sendMessage`.\n function getMessageFee(\n uint256 dstChainId,\n uint256 gasLimit,\n uint256 gasAirdrop,\n bytes memory message\n )\n external\n view\n returns (uint256)\n {\n return _getMessageFee(dstChainId, OptionsV1({gasLimit: gasLimit, gasAirdrop: gasAirdrop}), message.length);\n }\n\n /// @dev Internal logic for receiving messages. At this point the validity of the message is already checked.\n function _receiveMessage(\n uint256 srcChainId,\n bytes32 sender,\n uint256 dbNonce,\n uint64 entryIndex,\n bytes calldata message\n )\n internal\n override\n {\n emit MessageReceived(srcChainId, sender, dbNonce, entryIndex, message);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"3298:3757:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;3298:3757:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"3298:3757:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/ExampleAppV1.sol\":\"VersionedPayloadLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/ExampleAppV1.sol\":{\"keccak256\":\"0x0ccdc5cd2668a3193398a641a4992cc19f18ef7678c545b871d40e3864fa695b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0b91317ad3286b520b4c287e204cec6dc7b5f225b3c2fa2e6ceb5217da833922\",\"dweb:/ipfs/QmdbspYeU2QpvAvhYLb8R1qT2CZbo2mVkHkD6yxzwPFczm\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file diff --git a/sin-executor/contracts/mocks/optionslibexport/optionslibexport.abigen.go b/sin-executor/contracts/mocks/optionslibexport/optionslibexport.abigen.go index 6d49c0f9c0..640dac090f 100644 --- a/sin-executor/contracts/mocks/optionslibexport/optionslibexport.abigen.go +++ b/sin-executor/contracts/mocks/optionslibexport/optionslibexport.abigen.go @@ -37,8 +37,8 @@ type OptionsV1 struct { // OptionsLibMetaData contains all meta data concerning the OptionsLib contract. var OptionsLibMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122099c1cf64c7e5ed06baa9609a2766e1c65fa0749d737b52577dbe02bb3317d12164736f6c63430008140033", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ceddc9626cd1aaef2a9f48baf87743ae318709c51b5ebbb8061b9804b9b53c6164736f6c63430008140033", } // OptionsLibABI is the input ABI used to generate the binding from. @@ -210,13 +210,13 @@ func (_OptionsLib *OptionsLibTransactorRaw) Transact(opts *bind.TransactOpts, me // OptionsLibMocksMetaData contains all meta data concerning the OptionsLibMocks contract. var OptionsLibMocksMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"convertable\",\"type\":\"address\"}],\"name\":\"addressToBytes32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"structOptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"structOptionsV1\",\"name\":\"options\",\"type\":\"tuple\"}],\"name\":\"encodeOptions\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"convertable\",\"type\":\"address\"}],\"name\":\"addressToBytes32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"structOptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"structOptionsV1\",\"name\":\"options\",\"type\":\"tuple\"}],\"name\":\"encodeOptions\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", Sigs: map[string]string{ "82c947b7": "addressToBytes32(address)", "d5e788a0": "decodeOptions(bytes)", "c551274c": "encodeOptions((uint256,uint256))", }, - Bin: "0x608060405234801561001057600080fd5b5061058a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806382c947b714610046578063c551274c1461006c578063d5e788a01461008c575b600080fd5b610059610054366004610216565b6100ba565b6040519081526020015b60405180910390f35b61007f61007a3660046102fa565b6100da565b604051610063919061039a565b61009f61009a3660046103f3565b6100e5565b60408051825181526020928301519281019290925201610063565b600073ffffffffffffffffffffffffffffffffffffffff82165b92915050565b60606100d482610102565b60408051808201909152600080825260208201526100d482610140565b60606100d460018360405160200161012c9190815181526020918201519181019190915260400190565b6040516020818303038152906040526101c8565b6040805180820190915260008082526020820152600080610160846101f4565b9092509050600160ff831610156101ac576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff8316600482015260240160405180910390fd5b808060200190518101906101c09190610473565b949350505050565b606082826040516020016101dd9291906104a5565b604051602081830303815290604052905092915050565b600060608280602001905181019061020c91906104c1565b9094909350915050565b60006020828403121561022857600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461024c57600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156102a5576102a5610253565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156102f2576102f2610253565b604052919050565b60006040828403121561030c57600080fd5b610314610282565b82358152602083013560208201528091505092915050565b60005b8381101561034757818101518382015260200161032f565b50506000910152565b6000815180845261036881602086016020860161032c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061024c6020830184610350565b600067ffffffffffffffff8211156103c7576103c7610253565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60006020828403121561040557600080fd5b813567ffffffffffffffff81111561041c57600080fd5b8201601f8101841361042d57600080fd5b803561044061043b826103ad565b6102ab565b81815285602083850101111561045557600080fd5b81602084016020830137600091810160200191909152949350505050565b60006040828403121561048557600080fd5b61048d610282565b82518152602083015160208201528091505092915050565b60ff831681526040602082015260006101c06040830184610350565b600080604083850312156104d457600080fd5b825160ff811681146104e557600080fd5b602084015190925067ffffffffffffffff81111561050257600080fd5b8301601f8101851361051357600080fd5b805161052161043b826103ad565b81815286602083850101111561053657600080fd5b61054782602083016020860161032c565b809350505050925092905056fea26469706673582212202463c00749d5cfce7243b122dd48b445941f35e6a5787b616682ac876fd6214f64736f6c63430008140033", + Bin: "0x608060405234801561001057600080fd5b506105f6806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806382c947b714610046578063c551274c1461006c578063d5e788a01461008c575b600080fd5b61005961005436600461033f565b6100ba565b6040519081526020015b60405180910390f35b61007f61007a3660046103cd565b6100da565b6040516100639190610423565b61009f61009a366004610474565b6100e5565b60408051825181526020928301519281019290925201610063565b600073ffffffffffffffffffffffffffffffffffffffff82165b92915050565b60606100d482610102565b60408051808201909152600080825260208201526100d482610140565b60606100d460018360405160200161012c9190815181526020918201519181019190915260400190565b6040516020818303038152906040526101ce565b6040805180820190915260008082526020820152600061015f836101fa565b9050600161ffff821610156101ab576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b6101b483610245565b8060200190518101906101c79190610543565b9392505050565b606082826040516020016101e3929190610575565b604051602081830303815290604052905092915050565b600060028251101561023a57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016101a29190610423565b506020015160f01c90565b606060028251101561028557816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016101a29190610423565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156102c2576102c2610375565b6040519080825280601f01601f1916602001820160405280156102ec576020820181803683370190505b50915060008160208401836022870160045afa905080610338576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561035157600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146101c757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156103c7576103c7610375565b60405290565b6000604082840312156103df57600080fd5b6103e76103a4565b82358152602083013560208201528091505092915050565b60005b8381101561041a578181015183820152602001610402565b50506000910152565b60208152600082518060208401526104428160408501602087016103ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60006020828403121561048657600080fd5b813567ffffffffffffffff8082111561049e57600080fd5b818401915084601f8301126104b257600080fd5b8135818111156104c4576104c4610375565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561050a5761050a610375565b8160405282815287602084870101111561052357600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006040828403121561055557600080fd5b61055d6103a4565b82518152602083015160208201528091505092915050565b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b168152600082516105b28160028501602087016103ff565b91909101600201939250505056fea26469706673582212202762f5810d1af93b5a8bc5d619102d7981ab2d211e9233305b7d1835cf5476d564736f6c63430008140033", } // OptionsLibMocksABI is the input ABI used to generate the binding from. @@ -486,7 +486,7 @@ func (_OptionsLibMocks *OptionsLibMocksCallerSession) EncodeOptions(options Opti // TypeCastsMetaData contains all meta data concerning the TypeCasts contract. var TypeCastsMetaData = &bind.MetaData{ ABI: "[]", - Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a0cfd1c9580b34a2c8b114d4320fa6c26056bbc32401197e5fbbdfc3e3e86e2a64736f6c63430008140033", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122011d41019079fd2883971fb523eac68f79dca9f5c9b1399e1d9ed07a58f02900864736f6c63430008140033", } // TypeCastsABI is the input ABI used to generate the binding from. @@ -655,3 +655,176 @@ func (_TypeCasts *TypeCastsTransactorRaw) Transfer(opts *bind.TransactOpts) (*ty func (_TypeCasts *TypeCastsTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { return _TypeCasts.Contract.contract.Transact(opts, method, params...) } + +// VersionedPayloadLibMetaData contains all meta data concerning the VersionedPayloadLib contract. +var VersionedPayloadLibMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}]", + Bin: "0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ae80c771c0d9e0079ecd5caa5e51872a85f846823e5d2e7f0d81e2cc91e6665364736f6c63430008140033", +} + +// VersionedPayloadLibABI is the input ABI used to generate the binding from. +// Deprecated: Use VersionedPayloadLibMetaData.ABI instead. +var VersionedPayloadLibABI = VersionedPayloadLibMetaData.ABI + +// VersionedPayloadLibBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use VersionedPayloadLibMetaData.Bin instead. +var VersionedPayloadLibBin = VersionedPayloadLibMetaData.Bin + +// DeployVersionedPayloadLib deploys a new Ethereum contract, binding an instance of VersionedPayloadLib to it. +func DeployVersionedPayloadLib(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *VersionedPayloadLib, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(VersionedPayloadLibBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// VersionedPayloadLib is an auto generated Go binding around an Ethereum contract. +type VersionedPayloadLib struct { + VersionedPayloadLibCaller // Read-only binding to the contract + VersionedPayloadLibTransactor // Write-only binding to the contract + VersionedPayloadLibFilterer // Log filterer for contract events +} + +// VersionedPayloadLibCaller is an auto generated read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibTransactor is an auto generated write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type VersionedPayloadLibFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// VersionedPayloadLibSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type VersionedPayloadLibSession struct { + Contract *VersionedPayloadLib // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type VersionedPayloadLibCallerSession struct { + Contract *VersionedPayloadLibCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// VersionedPayloadLibTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type VersionedPayloadLibTransactorSession struct { + Contract *VersionedPayloadLibTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// VersionedPayloadLibRaw is an auto generated low-level Go binding around an Ethereum contract. +type VersionedPayloadLibRaw struct { + Contract *VersionedPayloadLib // Generic contract binding to access the raw methods on +} + +// VersionedPayloadLibCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type VersionedPayloadLibCallerRaw struct { + Contract *VersionedPayloadLibCaller // Generic read-only contract binding to access the raw methods on +} + +// VersionedPayloadLibTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type VersionedPayloadLibTransactorRaw struct { + Contract *VersionedPayloadLibTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewVersionedPayloadLib creates a new instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLib(address common.Address, backend bind.ContractBackend) (*VersionedPayloadLib, error) { + contract, err := bindVersionedPayloadLib(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &VersionedPayloadLib{VersionedPayloadLibCaller: VersionedPayloadLibCaller{contract: contract}, VersionedPayloadLibTransactor: VersionedPayloadLibTransactor{contract: contract}, VersionedPayloadLibFilterer: VersionedPayloadLibFilterer{contract: contract}}, nil +} + +// NewVersionedPayloadLibCaller creates a new read-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibCaller(address common.Address, caller bind.ContractCaller) (*VersionedPayloadLibCaller, error) { + contract, err := bindVersionedPayloadLib(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibCaller{contract: contract}, nil +} + +// NewVersionedPayloadLibTransactor creates a new write-only instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibTransactor(address common.Address, transactor bind.ContractTransactor) (*VersionedPayloadLibTransactor, error) { + contract, err := bindVersionedPayloadLib(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &VersionedPayloadLibTransactor{contract: contract}, nil +} + +// NewVersionedPayloadLibFilterer creates a new log filterer instance of VersionedPayloadLib, bound to a specific deployed contract. +func NewVersionedPayloadLibFilterer(address common.Address, filterer bind.ContractFilterer) (*VersionedPayloadLibFilterer, error) { + contract, err := bindVersionedPayloadLib(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &VersionedPayloadLibFilterer{contract: contract}, nil +} + +// bindVersionedPayloadLib binds a generic wrapper to an already deployed contract. +func bindVersionedPayloadLib(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := VersionedPayloadLibMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.VersionedPayloadLibCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.VersionedPayloadLibTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_VersionedPayloadLib *VersionedPayloadLibCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _VersionedPayloadLib.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_VersionedPayloadLib *VersionedPayloadLibTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _VersionedPayloadLib.Contract.contract.Transact(opts, method, params...) +} diff --git a/sin-executor/contracts/mocks/optionslibexport/optionslibexport.contractinfo.json b/sin-executor/contracts/mocks/optionslibexport/optionslibexport.contractinfo.json index dcf5786fb0..147845e581 100644 --- a/sin-executor/contracts/mocks/optionslibexport/optionslibexport.contractinfo.json +++ b/sin-executor/contracts/mocks/optionslibexport/optionslibexport.contractinfo.json @@ -1 +1 @@ -{"solidity/OptionsLibExport.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122099c1cf64c7e5ed06baa9609a2766e1c65fa0749d737b52577dbe02bb3317d12164736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122099c1cf64c7e5ed06baa9609a2766e1c65fa0749d737b52577dbe02bb3317d12164736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"558:1958:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;558:1958:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"558:1958:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x40681fcd75b4ff3a23b4d5e36b6d5aa6af760bdf60981d4902604acef23ba6f4\",\"urls\":[\"bzz-raw://3016b4c389af71503c268421dbd4e6c00106f788e017e9dacaae2918e27e23bb\",\"dweb:/ipfs/QmPuVecuQAq8qBmtj8CVN1DYisXDmRHKno7FHzgzLbyjb1\"]}},\"version\":1}"},"hashes":{}},"solidity/OptionsLibExport.sol:OptionsLibMocks":{"code":"0x608060405234801561001057600080fd5b5061058a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806382c947b714610046578063c551274c1461006c578063d5e788a01461008c575b600080fd5b610059610054366004610216565b6100ba565b6040519081526020015b60405180910390f35b61007f61007a3660046102fa565b6100da565b604051610063919061039a565b61009f61009a3660046103f3565b6100e5565b60408051825181526020928301519281019290925201610063565b600073ffffffffffffffffffffffffffffffffffffffff82165b92915050565b60606100d482610102565b60408051808201909152600080825260208201526100d482610140565b60606100d460018360405160200161012c9190815181526020918201519181019190915260400190565b6040516020818303038152906040526101c8565b6040805180820190915260008082526020820152600080610160846101f4565b9092509050600160ff831610156101ac576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff8316600482015260240160405180910390fd5b808060200190518101906101c09190610473565b949350505050565b606082826040516020016101dd9291906104a5565b604051602081830303815290604052905092915050565b600060608280602001905181019061020c91906104c1565b9094909350915050565b60006020828403121561022857600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461024c57600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156102a5576102a5610253565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156102f2576102f2610253565b604052919050565b60006040828403121561030c57600080fd5b610314610282565b82358152602083013560208201528091505092915050565b60005b8381101561034757818101518382015260200161032f565b50506000910152565b6000815180845261036881602086016020860161032c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061024c6020830184610350565b600067ffffffffffffffff8211156103c7576103c7610253565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60006020828403121561040557600080fd5b813567ffffffffffffffff81111561041c57600080fd5b8201601f8101841361042d57600080fd5b803561044061043b826103ad565b6102ab565b81815285602083850101111561045557600080fd5b81602084016020830137600091810160200191909152949350505050565b60006040828403121561048557600080fd5b61048d610282565b82518152602083015160208201528091505092915050565b60ff831681526040602082015260006101c06040830184610350565b600080604083850312156104d457600080fd5b825160ff811681146104e557600080fd5b602084015190925067ffffffffffffffff81111561050257600080fd5b8301601f8101851361051357600080fd5b805161052161043b826103ad565b81815286602083850101111561053657600080fd5b61054782602083016020860161032c565b809350505050925092905056fea26469706673582212202463c00749d5cfce7243b122dd48b445941f35e6a5787b616682ac876fd6214f64736f6c63430008140033","runtime-code":"0x608060405234801561001057600080fd5b50600436106100415760003560e01c806382c947b714610046578063c551274c1461006c578063d5e788a01461008c575b600080fd5b610059610054366004610216565b6100ba565b6040519081526020015b60405180910390f35b61007f61007a3660046102fa565b6100da565b604051610063919061039a565b61009f61009a3660046103f3565b6100e5565b60408051825181526020928301519281019290925201610063565b600073ffffffffffffffffffffffffffffffffffffffff82165b92915050565b60606100d482610102565b60408051808201909152600080825260208201526100d482610140565b60606100d460018360405160200161012c9190815181526020918201519181019190915260400190565b6040516020818303038152906040526101c8565b6040805180820190915260008082526020820152600080610160846101f4565b9092509050600160ff831610156101ac576040517fbd91a21500000000000000000000000000000000000000000000000000000000815260ff8316600482015260240160405180910390fd5b808060200190518101906101c09190610473565b949350505050565b606082826040516020016101dd9291906104a5565b604051602081830303815290604052905092915050565b600060608280602001905181019061020c91906104c1565b9094909350915050565b60006020828403121561022857600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461024c57600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156102a5576102a5610253565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156102f2576102f2610253565b604052919050565b60006040828403121561030c57600080fd5b610314610282565b82358152602083013560208201528091505092915050565b60005b8381101561034757818101518382015260200161032f565b50506000910152565b6000815180845261036881602086016020860161032c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061024c6020830184610350565b600067ffffffffffffffff8211156103c7576103c7610253565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60006020828403121561040557600080fd5b813567ffffffffffffffff81111561041c57600080fd5b8201601f8101841361042d57600080fd5b803561044061043b826103ad565b6102ab565b81815285602083850101111561045557600080fd5b81602084016020830137600091810160200191909152949350505050565b60006040828403121561048557600080fd5b61048d610282565b82518152602083015160208201528091505092915050565b60ff831681526040602082015260006101c06040830184610350565b600080604083850312156104d457600080fd5b825160ff811681146104e557600080fd5b602084015190925067ffffffffffffffff81111561050257600080fd5b8301601f8101851361051357600080fd5b805161052161043b826103ad565b81815286602083850101111561053657600080fd5b61054782602083016020860161032c565b809350505050925092905056fea26469706673582212202463c00749d5cfce7243b122dd48b445941f35e6a5787b616682ac876fd6214f64736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"2874:465:0:-:0;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"2874:465:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3197:140;;;;;;:::i;:::-;;:::i;:::-;;;474:25:1;;;462:2;447:18;3197:140:0;;;;;;;;2905:143;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;3054:137::-;;;;;;:::i;:::-;;:::i;:::-;;;;3588:13:1;;3570:32;;3658:4;3646:17;;;3640:24;3618:20;;;3611:54;;;;3543:18;3054:137:0;3376:295:1;3197:140:0;3265:7;2672:22;;;3291:39;3284:46;3197:140;-1:-1:-1;;3197:140:0:o;2905:143::-;2975:12;3006:35;3033:7;3006:26;:35::i;3054:137::-;-1:-1:-1;;;;;;;;;;;;;;;;;3152:32:0;3179:4;3152:26;:32::i;1578:167::-;1652:12;1683:55;611:1;1729:7;1718:19;;;;;;;3588:13:1;;3570:32;;3658:4;3646:17;;;3640:24;3618:20;;;3611:54;;;;3558:2;3543:18;;3376:295;1718:19:0;;;;;;;;;;;;;1683:22;:55::i;1911:603::-;-1:-1:-1;;;;;;;;;;;;;;;;;2007:13:0;2022:20;2046:28;2069:4;2046:22;:28::i;:::-;2006:68;;-1:-1:-1;2006:68:0;-1:-1:-1;611:1:0;2088:20;;;;2084:95;;;2131:37;;;;;3848:4:1;3836:17;;2131:37:0;;;3818:36:1;3791:18;;2131:37:0;;;;;;;2084:95;2486:7;2475:32;;;;;;;;;;;;:::i;:::-;2468:39;1911:603;-1:-1:-1;;;;1911:603:0:o;845:158::-;937:12;979:7;988;968:28;;;;;;;;;:::i;:::-;;;;;;;;;;;;;961:35;;845:158;;;;:::o;1282:181::-;1356:13;1371:20;1435:4;1424:32;;;;;;;;;;;;:::i;:::-;1403:53;;;;-1:-1:-1;1282:181:0;-1:-1:-1;;1282:181:0:o;14:309:1:-;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;181:9;168:23;231:42;224:5;220:54;213:5;210:65;200:93;;289:1;286;279:12;200:93;312:5;14:309;-1:-1:-1;;;14:309:1:o;510:184::-;562:77;559:1;552:88;659:4;656:1;649:15;683:4;680:1;673:15;699:250;770:2;764:9;;;800:15;;845:18;830:34;;866:22;;;827:62;824:88;;;892:18;;:::i;:::-;928:2;921:22;699:250;:::o;954:334::-;1025:2;1019:9;1081:2;1071:13;;1086:66;1067:86;1055:99;;1184:18;1169:34;;1205:22;;;1166:62;1163:88;;;1231:18;;:::i;:::-;1267:2;1260:22;954:334;;-1:-1:-1;954:334:1:o;1293:341::-;1376:6;1429:2;1417:9;1408:7;1404:23;1400:32;1397:52;;;1445:1;1442;1435:12;1397:52;1471:21;;:::i;:::-;1528:9;1515:23;1508:5;1501:38;1599:2;1588:9;1584:18;1571:32;1566:2;1559:5;1555:14;1548:56;1623:5;1613:15;;;1293:341;;;;:::o;1639:250::-;1724:1;1734:113;1748:6;1745:1;1742:13;1734:113;;;1824:11;;;1818:18;1805:11;;;1798:39;1770:2;1763:10;1734:113;;;-1:-1:-1;;1881:1:1;1863:16;;1856:27;1639:250::o;1894:329::-;1935:3;1973:5;1967:12;2000:6;1995:3;1988:19;2016:76;2085:6;2078:4;2073:3;2069:14;2062:4;2055:5;2051:16;2016:76;:::i;:::-;2137:2;2125:15;2142:66;2121:88;2112:98;;;;2212:4;2108:109;;1894:329;-1:-1:-1;;1894:329:1:o;2228:217::-;2375:2;2364:9;2357:21;2338:4;2395:44;2435:2;2424:9;2420:18;2412:6;2395:44;:::i;2450:245::-;2498:4;2531:18;2523:6;2520:30;2517:56;;;2553:18;;:::i;:::-;-1:-1:-1;2610:2:1;2598:15;2615:66;2594:88;2684:4;2590:99;;2450:245::o;2700:671::-;2768:6;2821:2;2809:9;2800:7;2796:23;2792:32;2789:52;;;2837:1;2834;2827:12;2789:52;2877:9;2864:23;2910:18;2902:6;2899:30;2896:50;;;2942:1;2939;2932:12;2896:50;2965:22;;3018:4;3010:13;;3006:27;-1:-1:-1;2996:55:1;;3047:1;3044;3037:12;2996:55;3083:2;3070:16;3108:48;3124:31;3152:2;3124:31;:::i;:::-;3108:48;:::i;:::-;3179:2;3172:5;3165:17;3219:7;3214:2;3209;3205;3201:11;3197:20;3194:33;3191:53;;;3240:1;3237;3230:12;3191:53;3295:2;3290;3286;3282:11;3277:2;3270:5;3266:14;3253:45;3339:1;3318:14;;;3334:2;3314:23;3307:34;;;;3322:5;2700:671;-1:-1:-1;;;;2700:671:1:o;3865:338::-;3959:6;4012:2;4000:9;3991:7;3987:23;3983:32;3980:52;;;4028:1;4025;4018:12;3980:52;4054:21;;:::i;:::-;4104:9;4098:16;4091:5;4084:31;4168:2;4157:9;4153:18;4147:25;4142:2;4135:5;4131:14;4124:49;4192:5;4182:15;;;3865:338;;;;:::o;4208:295::-;4391:4;4383:6;4379:17;4368:9;4361:36;4433:2;4428;4417:9;4413:18;4406:30;4342:4;4453:44;4493:2;4482:9;4478:18;4470:6;4453:44;:::i;4508:797::-;4594:6;4602;4655:2;4643:9;4634:7;4630:23;4626:32;4623:52;;;4671:1;4668;4661:12;4623:52;4703:9;4697:16;4753:4;4746:5;4742:16;4735:5;4732:27;4722:55;;4773:1;4770;4763:12;4722:55;4845:2;4830:18;;4824:25;4796:5;;-1:-1:-1;4872:18:1;4861:30;;4858:50;;;4904:1;4901;4894:12;4858:50;4927:22;;4980:4;4972:13;;4968:27;-1:-1:-1;4958:55:1;;5009:1;5006;4999:12;4958:55;5038:2;5032:9;5063:48;5079:31;5107:2;5079:31;:::i;5063:48::-;5134:2;5127:5;5120:17;5174:7;5169:2;5164;5160;5156:11;5152:20;5149:33;5146:53;;;5195:1;5192;5185:12;5146:53;5208:67;5272:2;5267;5260:5;5256:14;5251:2;5247;5243:11;5208:67;:::i;:::-;5294:5;5284:15;;;;;4508:797;;;;;:::o","abiDefinition":[{"inputs":[{"internalType":"uint8","name":"version","type":"uint8"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[{"internalType":"address","name":"convertable","type":"address"}],"name":"addressToBytes32","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"decodeOptions","outputs":[{"components":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"}],"internalType":"struct OptionsV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"}],"internalType":"struct OptionsV1","name":"options","type":"tuple"}],"name":"encodeOptions","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"convertable\",\"type\":\"address\"}],\"name\":\"addressToBytes32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"struct OptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"struct OptionsV1\",\"name\":\"options\",\"type\":\"tuple\"}],\"name\":\"encodeOptions\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"OptionsLibMocks\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x40681fcd75b4ff3a23b4d5e36b6d5aa6af760bdf60981d4902604acef23ba6f4\",\"urls\":[\"bzz-raw://3016b4c389af71503c268421dbd4e6c00106f788e017e9dacaae2918e27e23bb\",\"dweb:/ipfs/QmPuVecuQAq8qBmtj8CVN1DYisXDmRHKno7FHzgzLbyjb1\"]}},\"version\":1}"},"hashes":{"addressToBytes32(address)":"82c947b7","decodeOptions(bytes)":"d5e788a0","encodeOptions((uint256,uint256))":"c551274c"}},"solidity/OptionsLibExport.sol:TypeCasts":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a0cfd1c9580b34a2c8b114d4320fa6c26056bbc32401197e5fbbdfc3e3e86e2a64736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220a0cfd1c9580b34a2c8b114d4320fa6c26056bbc32401197e5fbbdfc3e3e86e2a64736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n uint8 constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint8 version);\n\n /// @notice Encodes versioned options into a bytes format.\n /// @param version The version of the options.\n /// @param options The options to encode.\n function encodeVersionedOptions(uint8 version, bytes memory options) internal pure returns (bytes memory) {\n return abi.encode(version, options);\n }\n\n /// @notice Decodes versioned options from a bytes format back into a version and options.\n /// @param data The versioned options data in bytes format.\n /// @return version The version of the options.\n /// @return options The options as bytes.\n function decodeVersionedOptions(bytes memory data) internal pure returns (uint8 version, bytes memory options) {\n (version, options) = abi.decode(data, (uint8, bytes));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return encodeVersionedOptions(OPTIONS_V1, abi.encode(options));\n }\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal pure returns (OptionsV1 memory) {\n (uint8 version, bytes memory options) = decodeVersionedOptions(data);\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(options, (OptionsV1));\n }\n}\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"2551:280:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;2551:280:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"2551:280:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"TypeCasts\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x40681fcd75b4ff3a23b4d5e36b6d5aa6af760bdf60981d4902604acef23ba6f4\",\"urls\":[\"bzz-raw://3016b4c389af71503c268421dbd4e6c00106f788e017e9dacaae2918e27e23bb\",\"dweb:/ipfs/QmPuVecuQAq8qBmtj8CVN1DYisXDmRHKno7FHzgzLbyjb1\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file +{"solidity/OptionsLibExport.sol:OptionsLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ceddc9626cd1aaef2a9f48baf87743ae318709c51b5ebbb8061b9804b9b53c6164736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ceddc9626cd1aaef2a9f48baf87743ae318709c51b5ebbb8061b9804b9b53c6164736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"4738:1233:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;4738:1233:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"4738:1233:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"}],"userDoc":{"kind":"user","methods":{},"notice":"A library for encoding and decoding Interchain options related to interchain messages.","version":1},"developerDoc":{"kind":"dev","methods":{},"title":"OptionsLib","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"title\":\"OptionsLib\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"notice\":\"A library for encoding and decoding Interchain options related to interchain messages.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"OptionsLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x4ce8e3db7bd6012066c69b2789cc045ff8633da199b576f9e1b6e6bf2801e39c\",\"urls\":[\"bzz-raw://3254d79e9717f010a0e672934fa720e8e2a21951f08ac3c30ee95a4bef05ced3\",\"dweb:/ipfs/QmNbxZoEWCwrxqfV8r7RfkheH6d34DpE8KuDh3Tgqp1XvN\"]}},\"version\":1}"},"hashes":{}},"solidity/OptionsLibExport.sol:OptionsLibMocks":{"code":"0x608060405234801561001057600080fd5b506105f6806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806382c947b714610046578063c551274c1461006c578063d5e788a01461008c575b600080fd5b61005961005436600461033f565b6100ba565b6040519081526020015b60405180910390f35b61007f61007a3660046103cd565b6100da565b6040516100639190610423565b61009f61009a366004610474565b6100e5565b60408051825181526020928301519281019290925201610063565b600073ffffffffffffffffffffffffffffffffffffffff82165b92915050565b60606100d482610102565b60408051808201909152600080825260208201526100d482610140565b60606100d460018360405160200161012c9190815181526020918201519181019190915260400190565b6040516020818303038152906040526101ce565b6040805180820190915260008082526020820152600061015f836101fa565b9050600161ffff821610156101ab576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b6101b483610245565b8060200190518101906101c79190610543565b9392505050565b606082826040516020016101e3929190610575565b604051602081830303815290604052905092915050565b600060028251101561023a57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016101a29190610423565b506020015160f01c90565b606060028251101561028557816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016101a29190610423565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156102c2576102c2610375565b6040519080825280601f01601f1916602001820160405280156102ec576020820181803683370190505b50915060008160208401836022870160045afa905080610338576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561035157600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146101c757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156103c7576103c7610375565b60405290565b6000604082840312156103df57600080fd5b6103e76103a4565b82358152602083013560208201528091505092915050565b60005b8381101561041a578181015183820152602001610402565b50506000910152565b60208152600082518060208401526104428160408501602087016103ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60006020828403121561048657600080fd5b813567ffffffffffffffff8082111561049e57600080fd5b818401915084601f8301126104b257600080fd5b8135818111156104c4576104c4610375565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561050a5761050a610375565b8160405282815287602084870101111561052357600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006040828403121561055557600080fd5b61055d6103a4565b82518152602083015160208201528091505092915050565b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b168152600082516105b28160028501602087016103ff565b91909101600201939250505056fea26469706673582212202762f5810d1af93b5a8bc5d619102d7981ab2d211e9233305b7d1835cf5476d564736f6c63430008140033","runtime-code":"0x608060405234801561001057600080fd5b50600436106100415760003560e01c806382c947b714610046578063c551274c1461006c578063d5e788a01461008c575b600080fd5b61005961005436600461033f565b6100ba565b6040519081526020015b60405180910390f35b61007f61007a3660046103cd565b6100da565b6040516100639190610423565b61009f61009a366004610474565b6100e5565b60408051825181526020928301519281019290925201610063565b600073ffffffffffffffffffffffffffffffffffffffff82165b92915050565b60606100d482610102565b60408051808201909152600080825260208201526100d482610140565b60606100d460018360405160200161012c9190815181526020918201519181019190915260400190565b6040516020818303038152906040526101ce565b6040805180820190915260008082526020820152600061015f836101fa565b9050600161ffff821610156101ab576040517fb94fa72500000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b6101b483610245565b8060200190518101906101c79190610543565b9392505050565b606082826040516020016101e3929190610575565b604051602081830303815290604052905092915050565b600060028251101561023a57816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016101a29190610423565b506020015160f01c90565b606060028251101561028557816040517f659cf9fa0000000000000000000000000000000000000000000000000000000081526004016101a29190610423565b81517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe018067ffffffffffffffff8111156102c2576102c2610375565b6040519080825280601f01601f1916602001820160405280156102ec576020820181803683370190505b50915060008160208401836022870160045afa905080610338576040517f101e44fa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050919050565b60006020828403121561035157600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146101c757600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156103c7576103c7610375565b60405290565b6000604082840312156103df57600080fd5b6103e76103a4565b82358152602083013560208201528091505092915050565b60005b8381101561041a578181015183820152602001610402565b50506000910152565b60208152600082518060208401526104428160408501602087016103ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60006020828403121561048657600080fd5b813567ffffffffffffffff8082111561049e57600080fd5b818401915084601f8301126104b257600080fd5b8135818111156104c4576104c4610375565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561050a5761050a610375565b8160405282815287602084870101111561052357600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006040828403121561055557600080fd5b61055d6103a4565b82518152602083015160208201528091505092915050565b7fffff0000000000000000000000000000000000000000000000000000000000008360f01b168152600082516105b28160028501602087016103ff565b91909101600201939250505056fea26469706673582212202762f5810d1af93b5a8bc5d619102d7981ab2d211e9233305b7d1835cf5476d564736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"6014:465:0:-:0;;;;;;;;;;;;;;;;;;;","srcMapRuntime":"6014:465:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6337:140;;;;;;:::i;:::-;;:::i;:::-;;;474:25:1;;;462:2;447:18;6337:140:0;;;;;;;;6045:143;;;;;;:::i;:::-;;:::i;:::-;;;;;;;:::i;6194:137::-;;;;;;:::i;:::-;;:::i;:::-;;;;3208:13:1;;3190:32;;3278:4;3266:17;;;3260:24;3238:20;;;3231:54;;;;3163:18;6194:137:0;2992:299:1;6337:140:0;6405:7;195:22;;;6431:39;6424:46;6337:140;-1:-1:-1;;6337:140:0:o;6045:143::-;6115:12;6146:35;6173:7;6146:26;:35::i;6194:137::-;-1:-1:-1;;;;;;;;;;;;;;;;;6292:32:0;6319:4;6292:26;:32::i;5782:187::-;5856:12;5887:75;4843:1;5953:7;5942:19;;;;;;;3208:13:1;;3190:32;;3278:4;3266:17;;;3260:24;3238:20;;;3231:54;;;;3178:2;3163:18;;2992:299;5942:19:0;;;;;;;;;;;;;5887:42;:75::i;5068:599::-;-1:-1:-1;;;;;;;;;;;;;;;;;5163:14:0;5180:27;:4;:25;:27::i;:::-;5163:44;-1:-1:-1;4843:1:0;5221:20;;;;5217:95;;;5264:37;;;;;3470:6:1;3458:19;;5264:37:0;;;3440:38:1;3413:18;;5264:37:0;;;;;;;;5217:95;5619:27;:4;:25;:27::i;:::-;5608:52;;;;;;;;;;;;:::i;:::-;5601:59;5068:599;-1:-1:-1;;;5068:599:0:o;916:165::-;1009:12;1057:7;1066;1040:34;;;;;;;;;:::i;:::-;;;;;;;;;;;;;1033:41;;916:165;;;;:::o;2354:496::-;2438:14;630:1;2468:16;:23;:40;2464:122;;;2558:16;2531:44;;;;;;;;;;;:::i;2464:122::-;-1:-1:-1;2827:4:0;2805:27;2799:34;2794:3;2790:44;;2354:496::o;3164:1053::-;3248:20;630:1;3284:16;:23;:40;3280:122;;;3374:16;3347:44;;;;;;;;;;;:::i;3280:122::-;3560:23;;:40;;;3630:17;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3630:17:0;;3620:27;;3771:8;4107:6;4100:4;4091:7;4087:18;4079:6;4072:4;4054:16;4050:27;4044:4;4037:5;4026:88;4019:95;;4138:3;4133:78;;4164:36;;;;;;;;;;;;;;4133:78;3270:947;;3164:1053;;;:::o;14:309:1:-;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;181:9;168:23;231:42;224:5;220:54;213:5;210:65;200:93;;289:1;286;279:12;510:184;562:77;559:1;552:88;659:4;656:1;649:15;683:4;680:1;673:15;699:246;766:2;760:9;;;796:15;;841:18;826:34;;862:22;;;823:62;820:88;;;888:18;;:::i;:::-;924:2;917:22;699:246;:::o;950:339::-;1035:6;1088:2;1076:9;1067:7;1063:23;1059:32;1056:52;;;1104:1;1101;1094:12;1056:52;1130:17;;:::i;:::-;1183:9;1170:23;1163:5;1156:38;1254:2;1243:9;1239:18;1226:32;1221:2;1214:5;1210:14;1203:56;1278:5;1268:15;;;950:339;;;;:::o;1294:250::-;1379:1;1389:113;1403:6;1400:1;1397:13;1389:113;;;1479:11;;;1473:18;1460:11;;;1453:39;1425:2;1418:10;1389:113;;;-1:-1:-1;;1536:1:1;1518:16;;1511:27;1294:250::o;1549:453::-;1696:2;1685:9;1678:21;1659:4;1728:6;1722:13;1771:6;1766:2;1755:9;1751:18;1744:34;1787:79;1859:6;1854:2;1843:9;1839:18;1834:2;1826:6;1822:15;1787:79;:::i;:::-;1918:2;1906:15;1923:66;1902:88;1887:104;;;;1993:2;1883:113;;1549:453;-1:-1:-1;;1549:453:1:o;2007:980::-;2075:6;2128:2;2116:9;2107:7;2103:23;2099:32;2096:52;;;2144:1;2141;2134:12;2096:52;2184:9;2171:23;2213:18;2254:2;2246:6;2243:14;2240:34;;;2270:1;2267;2260:12;2240:34;2308:6;2297:9;2293:22;2283:32;;2353:7;2346:4;2342:2;2338:13;2334:27;2324:55;;2375:1;2372;2365:12;2324:55;2411:2;2398:16;2433:2;2429;2426:10;2423:36;;;2439:18;;:::i;:::-;2573:2;2567:9;2635:4;2627:13;;2478:66;2623:22;;;2647:2;2619:31;2615:40;2603:53;;;2671:18;;;2691:22;;;2668:46;2665:72;;;2717:18;;:::i;:::-;2757:10;2753:2;2746:22;2792:2;2784:6;2777:18;2832:7;2827:2;2822;2818;2814:11;2810:20;2807:33;2804:53;;;2853:1;2850;2843:12;2804:53;2909:2;2904;2900;2896:11;2891:2;2883:6;2879:15;2866:46;2954:1;2932:15;;;2949:2;2928:24;2921:35;;;;-1:-1:-1;2936:6:1;2007:980;-1:-1:-1;;;;;2007:980:1:o;3489:336::-;3585:6;3638:2;3626:9;3617:7;3613:23;3609:32;3606:52;;;3654:1;3651;3644:12;3606:52;3680:17;;:::i;:::-;3726:9;3720:16;3713:5;3706:31;3790:2;3779:9;3775:18;3769:25;3764:2;3757:5;3753:14;3746:49;3814:5;3804:15;;;3489:336;;;;:::o;3830:440::-;4037:66;4028:6;4023:3;4019:16;4015:89;4010:3;4003:102;3985:3;4134:6;4128:13;4150:74;4217:6;4213:1;4208:3;4204:11;4197:4;4189:6;4185:17;4150:74;:::i;:::-;4244:16;;;;4262:1;4240:24;;3830:440;-1:-1:-1;;;3830:440:1:o","abiDefinition":[{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"OptionsLib__IncorrectVersion","type":"error"},{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"},{"inputs":[{"internalType":"address","name":"convertable","type":"address"}],"name":"addressToBytes32","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"decodeOptions","outputs":[{"components":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"}],"internalType":"struct OptionsV1","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"gasLimit","type":"uint256"},{"internalType":"uint256","name":"gasAirdrop","type":"uint256"}],"internalType":"struct OptionsV1","name":"options","type":"tuple"}],"name":"encodeOptions","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"version\",\"type\":\"uint16\"}],\"name\":\"OptionsLib__IncorrectVersion\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"convertable\",\"type\":\"address\"}],\"name\":\"addressToBytes32\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"decodeOptions\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"struct OptionsV1\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasAirdrop\",\"type\":\"uint256\"}],\"internalType\":\"struct OptionsV1\",\"name\":\"options\",\"type\":\"tuple\"}],\"name\":\"encodeOptions\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"OptionsLibMocks\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x4ce8e3db7bd6012066c69b2789cc045ff8633da199b576f9e1b6e6bf2801e39c\",\"urls\":[\"bzz-raw://3254d79e9717f010a0e672934fa720e8e2a21951f08ac3c30ee95a4bef05ced3\",\"dweb:/ipfs/QmNbxZoEWCwrxqfV8r7RfkheH6d34DpE8KuDh3Tgqp1XvN\"]}},\"version\":1}"},"hashes":{"addressToBytes32(address)":"82c947b7","decodeOptions(bytes)":"d5e788a0","encodeOptions((uint256,uint256))":"c551274c"}},"solidity/OptionsLibExport.sol:TypeCasts":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122011d41019079fd2883971fb523eac68f79dca9f5c9b1399e1d9ed07a58f02900864736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea264697066735822122011d41019079fd2883971fb523eac68f79dca9f5c9b1399e1d9ed07a58f02900864736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"74:280:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;74:280:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"74:280:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"TypeCasts\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x4ce8e3db7bd6012066c69b2789cc045ff8633da199b576f9e1b6e6bf2801e39c\",\"urls\":[\"bzz-raw://3254d79e9717f010a0e672934fa720e8e2a21951f08ac3c30ee95a4bef05ced3\",\"dweb:/ipfs/QmNbxZoEWCwrxqfV8r7RfkheH6d34DpE8KuDh3Tgqp1XvN\"]}},\"version\":1}"},"hashes":{}},"solidity/OptionsLibExport.sol:VersionedPayloadLib":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ae80c771c0d9e0079ecd5caa5e51872a85f846823e5d2e7f0d81e2cc91e6665364736f6c63430008140033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220ae80c771c0d9e0079ecd5caa5e51872a85f846823e5d2e7f0d81e2cc91e6665364736f6c63430008140033","info":{"source":"pragma solidity =0.8.20 ^0.8.0 ^0.8.13;\n\n// contracts/libs/TypeCasts.sol\n\nlibrary TypeCasts {\n function addressToBytes32(address addr) internal pure returns (bytes32) {\n return bytes32(uint256(uint160(addr)));\n }\n\n function bytes32ToAddress(bytes32 b) internal pure returns (address) {\n return address(uint160(uint256(b)));\n }\n}\n\n// contracts/libs/VersionedPayload.sol\n\n// solhint-disable no-inline-assembly\n// solhint-disable ordering\nlibrary VersionedPayloadLib {\n /// @notice Amount of bytes reserved for the version (uint16) in the versioned payload\n uint256 internal constant VERSION_LENGTH = 2;\n\n error VersionedPayload__TooShort(bytes versionedPayload);\n error VersionedPayload__PrecompileFailed();\n\n /// @notice Encodes the versioned payload into a single bytes array.\n /// @param version The payload's version.\n /// @param payload The payload to encode.\n function encodeVersionedPayload(uint16 version, bytes memory payload) internal pure returns (bytes memory) {\n return abi.encodePacked(version, payload);\n }\n\n /// @notice Extracts the version from the versioned payload (calldata reference).\n /// @param versionedPayload The versioned payload (calldata reference).\n function getVersion(bytes calldata versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n version := shr(240, calldataload(versionedPayload.offset))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (calldata reference).\n /// @dev The extracted payload is also returned as a calldata reference.\n /// @param versionedPayload The versioned payload.\n function getPayload(bytes calldata versionedPayload) internal pure returns (bytes calldata) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n return versionedPayload[VERSION_LENGTH:];\n }\n\n /// @notice Extracts the version from the versioned payload (memory reference).\n /// @param versionedPayload The versioned payload (memory reference).\n function getVersionFromMemory(bytes memory versionedPayload) internal pure returns (uint16 version) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n assembly {\n // We are only interested in the highest 16 bits of the loaded full 32 bytes word.\n // We add 0x20 to skip the length of the bytes array.\n version := shr(240, mload(add(versionedPayload, 0x20)))\n }\n }\n\n /// @notice Extracts the payload from the versioned payload (memory reference).\n /// @dev The extracted payload is copied into a new memory location. Use `getPayload` when possible\n /// to avoid extra memory allocation.\n /// @param versionedPayload The versioned payload (memory reference).\n function getPayloadFromMemory(bytes memory versionedPayload) internal view returns (bytes memory payload) {\n if (versionedPayload.length \u003c VERSION_LENGTH) {\n revert VersionedPayload__TooShort(versionedPayload);\n }\n // Figure how many bytes to copy and allocate the memory for the extracted payload.\n uint256 toCopy;\n unchecked {\n toCopy = versionedPayload.length - VERSION_LENGTH;\n }\n payload = new bytes(toCopy);\n // Use identity precompile (0x04) to copy the payload. Unlike MCOPY, this is available on all EVM chains.\n bool res;\n assembly {\n // We add 0x20 to skip the length of the bytes array.\n // We add 0x02 to skip the 2 bytes reserved for the version.\n // Copy the payload to the previously allocated memory.\n res := staticcall(gas(), 0x04, add(versionedPayload, 0x22), toCopy, add(payload, 0x20), toCopy)\n }\n if (!res) {\n revert VersionedPayload__PrecompileFailed();\n }\n }\n}\n\n// contracts/libs/Options.sol\n\n/// @notice Struct to hold V1 of options data.\n/// @dev Next versions have to use the fields from the previous version and add new fields at the end.\n/// @param gasLimit The gas limit for the transaction.\n/// @param gasAirdrop The amount of gas to airdrop.\nstruct OptionsV1 {\n uint256 gasLimit;\n uint256 gasAirdrop;\n}\n\nusing OptionsLib for OptionsV1 global;\n\n/// @title OptionsLib\n/// @notice A library for encoding and decoding Interchain options related to interchain messages.\nlibrary OptionsLib {\n using VersionedPayloadLib for bytes;\n\n uint16 internal constant OPTIONS_V1 = 1;\n\n error OptionsLib__IncorrectVersion(uint16 version);\n\n /// @notice Decodes options (V1 or higher) from a bytes format back into an OptionsV1 struct.\n /// @param data The options data in bytes format.\n function decodeOptionsV1(bytes memory data) internal view returns (OptionsV1 memory) {\n uint16 version = data.getVersionFromMemory();\n if (version \u003c OPTIONS_V1) {\n revert OptionsLib__IncorrectVersion(version);\n }\n // Structs of the same version will always be decoded correctly.\n // Following versions will be decoded correctly if they have the same fields as the previous version,\n // and new fields at the end: abi.decode ignores the extra bytes in the decoded payload.\n return abi.decode(data.getPayloadFromMemory(), (OptionsV1));\n }\n\n /// @notice Encodes V1 options into a bytes format.\n /// @param options The OptionsV1 to encode.\n function encodeOptionsV1(OptionsV1 memory options) internal pure returns (bytes memory) {\n return VersionedPayloadLib.encodeVersionedPayload(OPTIONS_V1, abi.encode(options));\n }\n}\n\n// contracts/mocks/OptionsLibExport.sol\n\ncontract OptionsLibMocks {\n function encodeOptions(OptionsV1 memory options) public view returns (bytes memory) {\n return OptionsLib.encodeOptionsV1(options);\n }\n\n function decodeOptions(bytes memory data) public view returns (OptionsV1 memory) {\n return OptionsLib.decodeOptionsV1(data);\n }\n\n function addressToBytes32(address convertable) public view returns (bytes32) {\n return TypeCasts.addressToBytes32(convertable);\n }\n}\n","language":"Solidity","languageVersion":"0.8.20","compilerVersion":"0.8.20","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../ --evm-version=istanbul","srcMap":"462:3757:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;462:3757:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"462:3757:0:-:0;;;;;;;;","abiDefinition":[{"inputs":[],"name":"VersionedPayload__PrecompileFailed","type":"error"},{"inputs":[{"internalType":"bytes","name":"versionedPayload","type":"bytes"}],"name":"VersionedPayload__TooShort","type":"error"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.20+commit.a1b79de6\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"VersionedPayload__PrecompileFailed\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"versionedPayload\",\"type\":\"bytes\"}],\"name\":\"VersionedPayload__TooShort\",\"type\":\"error\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/OptionsLibExport.sol\":\"VersionedPayloadLib\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/OptionsLibExport.sol\":{\"keccak256\":\"0x4ce8e3db7bd6012066c69b2789cc045ff8633da199b576f9e1b6e6bf2801e39c\",\"urls\":[\"bzz-raw://3254d79e9717f010a0e672934fa720e8e2a21951f08ac3c30ee95a4bef05ced3\",\"dweb:/ipfs/QmNbxZoEWCwrxqfV8r7RfkheH6d34DpE8KuDh3Tgqp1XvN\"]}},\"version\":1}"},"hashes":{}}} \ No newline at end of file