diff --git a/abi-bindings/go/Teleporter/TeleporterMessenger/TeleporterMessenger.go b/abi-bindings/go/Teleporter/TeleporterMessenger/TeleporterMessenger.go index b9e2c35db..7a8ef96f1 100644 --- a/abi-bindings/go/Teleporter/TeleporterMessenger/TeleporterMessenger.go +++ b/abi-bindings/go/Teleporter/TeleporterMessenger/TeleporterMessenger.go @@ -66,7 +66,7 @@ type TeleporterMessageReceipt struct { // TeleporterMessengerMetaData contains all meta data concerning the TeleporterMessenger contract. var TeleporterMessengerMetaData = &bind.MetaData{ ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"feeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"structTeleporterFeeInfo\",\"name\":\"updatedFeeInfo\",\"type\":\"tuple\"}],\"name\":\"AddFeeAmount\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"MessageExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"receivedMessageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"internalType\":\"structTeleporterMessageReceipt[]\",\"name\":\"receipts\",\"type\":\"tuple[]\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"indexed\":false,\"internalType\":\"structTeleporterMessage\",\"name\":\"message\",\"type\":\"tuple\"}],\"name\":\"MessageExecutionFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"deliverer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"rewardRedeemer\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"receivedMessageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"internalType\":\"structTeleporterMessageReceipt[]\",\"name\":\"receipts\",\"type\":\"tuple[]\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"indexed\":false,\"internalType\":\"structTeleporterMessage\",\"name\":\"message\",\"type\":\"tuple\"}],\"name\":\"ReceiveCrossChainMessage\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RelayerRewardsRedeemed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"receivedMessageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"internalType\":\"structTeleporterMessageReceipt[]\",\"name\":\"receipts\",\"type\":\"tuple[]\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"indexed\":false,\"internalType\":\"structTeleporterMessage\",\"name\":\"message\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"feeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"indexed\":false,\"internalType\":\"structTeleporterFeeInfo\",\"name\":\"feeInfo\",\"type\":\"tuple\"}],\"name\":\"SendCrossChainMessage\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"WARP_MESSENGER\",\"outputs\":[{\"internalType\":\"contractIWarpMessenger\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"feeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"additionalFeeAmount\",\"type\":\"uint256\"}],\"name\":\"addFeeAmount\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"blockchainID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"relayer\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"}],\"name\":\"checkRelayerRewardAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"getFeeInfo\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"getMessageHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"}],\"name\":\"getNextMessageID\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getReceiptAtIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"receivedMessageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"internalType\":\"structTeleporterMessageReceipt\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"}],\"name\":\"getReceiptQueueSize\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"getRelayerRewardAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"}],\"name\":\"latestMessageIDs\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"messageReceived\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sourceBlockchainID\",\"type\":\"bytes32\"}],\"name\":\"receiptQueues\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"first\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"messageIndex\",\"type\":\"uint32\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"name\":\"receiveCrossChainMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sourceBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"receivedFailedMessageHashes\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"messageHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"feeAsset\",\"type\":\"address\"}],\"name\":\"redeemRelayerRewards\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"receivedMessageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"internalType\":\"structTeleporterMessageReceipt[]\",\"name\":\"receipts\",\"type\":\"tuple[]\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structTeleporterMessage\",\"name\":\"message\",\"type\":\"tuple\"}],\"name\":\"retryMessageExecution\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"senderAddress\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"receivedMessageID\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"relayerRewardAddress\",\"type\":\"address\"}],\"internalType\":\"structTeleporterMessageReceipt[]\",\"name\":\"receipts\",\"type\":\"tuple[]\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structTeleporterMessage\",\"name\":\"message\",\"type\":\"tuple\"}],\"name\":\"retrySendCrossChainMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"feeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structTeleporterFeeInfo\",\"name\":\"feeInfo\",\"type\":\"tuple\"},{\"internalType\":\"uint256\",\"name\":\"requiredGasLimit\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structTeleporterMessageInput\",\"name\":\"messageInput\",\"type\":\"tuple\"}],\"name\":\"sendCrossChainMessage\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"originBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256[]\",\"name\":\"messageIDs\",\"type\":\"uint256[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"feeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structTeleporterFeeInfo\",\"name\":\"feeInfo\",\"type\":\"tuple\"},{\"internalType\":\"address[]\",\"name\":\"allowedRelayerAddresses\",\"type\":\"address[]\"}],\"name\":\"sendSpecifiedReceipts\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"destinationBlockchainID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"messageID\",\"type\":\"uint256\"}],\"name\":\"sentMessageInfo\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"messageHash\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"feeTokenAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"internalType\":\"structTeleporterFeeInfo\",\"name\":\"feeInfo\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50600160008190558055613051806100296000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c8063892bf412116100b8578063ccb5f8091161007c578063ccb5f80914610366578063d127dc9b14610379578063df20e8bc14610382578063e03555df14610395578063e6e67bd5146103b8578063fc2d6197146103f457600080fd5b8063892bf412146102c1578063af402850146102e1578063b771b3bc146102f4578063c473eef814610302578063c9bb11431461033b57600080fd5b80632bc8b0bf116100ff5780632bc8b0bf146101bd57806333e890fe146101d0578063624488501461021c57806366533d121461022f57806382f2c43a1461028f57600080fd5b8063191eb6981461013c57806319570c7414610162578063220c95681461017757806322296c3a1461018a57806329ec9beb1461019d575b600080fd5b61014f61014a3660046120cc565b610407565b6040519081526020015b60405180910390f35b61017561017036600461218c565b61062a565b005b61014f6101853660046121cb565b610865565b6101756101983660046121ed565b610886565b61014f6101ab36600461220a565b60036020526000908152604090205481565b61014f6101cb36600461220a565b61097b565b6102046101de3660046121cb565b60009182526007602090815260408084209284529190529020546001600160a01b031690565b6040516001600160a01b039091168152602001610159565b61014f61022a366004612223565b610992565b61028161023d3660046121cb565b60056020908152600092835260408084208252918352918190208054825180840190935260018201546001600160a01b031683526002909101549282019290925282565b60405161015992919061225d565b6102a261029d3660046121cb565b6109f0565b604080516001600160a01b039093168352602083019190915201610159565b6102d46102cf3660046121cb565b610a39565b6040516101599190612284565b6101756102ef3660046122a4565b610a6c565b6102046005600160991b0181565b61014f6103103660046122f2565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b61014f6103493660046121cb565b600660209081526000928352604080842090915290825290205481565b610175610374366004612320565b610c01565b61014f60025481565b61014f61039036600461220a565b611113565b6103a86103a33660046121cb565b61111e565b6040519015158152602001610159565b6103df6103c636600461220a565b6004602052600090815260409020805460019091015482565b60408051928352602083019190915201610159565b6101756104023660046122a4565b611148565b60006001600054146104345760405162461bcd60e51b815260040161042b90612347565b60405180910390fd5b60026000908155856001600160401b038111156104535761045361238a565b60405190808252806020026020018201604052801561049857816020015b60408051808201909152600080825260208201528152602001906001900390816104715790505b50905060005b868110156105955760008888838181106104ba576104ba6123a0565b60008d815260076020908152604080832093820295909501358083529290529290922054919250506001600160a01b0316806105475760405162461bcd60e51b815260206004820152602660248201527f54656c65706f727465724d657373656e6765723a2072656365697074206e6f7460448201526508199bdd5b9960d21b606482015260840161042b565b6040518060400160405280838152602001826001600160a01b0316815250848481518110610577576105776123a0565b602002602001018190525050508061058e906123cc565b905061049e565b506040805160c081018252898152600060208201526106199181016105bf368990038901896124bd565b815260200160008152602001868680806020026020016040519081016040528093929190818152602001838360200280828437600092018290525093855250506040805192835260208084019091529092015250826113a2565b600160005598975050505050505050565b60016000541461064c5760405162461bcd60e51b815260040161042b90612347565b6002600055806106b65760405162461bcd60e51b815260206004820152602f60248201527f54656c65706f727465724d657373656e6765723a207a65726f2061646469746960448201526e1bdb985b0819995948185b5bdd5b9d608a1b606482015260840161042b565b6001600160a01b0382166106dc5760405162461bcd60e51b815260040161042b906124d9565b60008481526005602090815260408083208684529091529020546107125760405162461bcd60e51b815260040161042b9061252d565b60008481526005602090815260408083208684529091529020600101546001600160a01b038381169116146107af5760405162461bcd60e51b815260206004820152603760248201527f54656c65706f727465724d657373656e6765723a20696e76616c69642066656560448201527f20617373657420636f6e74726163742061646472657373000000000000000000606482015260840161042b565b60006107bb83836115d4565b60008681526005602090815260408083208884529091528120600201805492935083929091906107ec908490612573565b90915550506000858152600560209081526040808320878452825291829020825160018201546001600160a01b0316815260029091015491810191909152859187917f28fe05eedf0479c9159e5b6dd2a28c93fa1a408eba22dc801fd9bc493a7fc0c2910160405180910390a350506001600055505050565b60008281526005602090815260408083208484529091529020545b92915050565b3360009081526008602090815260408083206001600160a01b0385168452909152902054806109085760405162461bcd60e51b815260206004820152602860248201527f54656c65706f727465724d657373656e6765723a206e6f2072657761726420746044820152676f2072656465656d60c01b606482015260840161042b565b3360008181526008602090815260408083206001600160a01b03871680855290835281842093909355518481529192917f3294c84e5b0f29d9803655319087207bc94f4db29f7927846944822773780b88910160405180910390a36109776001600160a01b038316338361173c565b5050565b6000818152600460205260408120610880906117a4565b60006001600054146109b65760405162461bcd60e51b815260040161042b90612347565b60026000556109e56109c783612695565b833560009081526004602052604090206109e0906117b7565b6113a2565b600160005592915050565b6000828152600560209081526040808320848452825291829020825180840190935260018101546001600160a01b031680845260029091015492909101829052905b9250929050565b60408051808201909152600080825260208201526000838152600460205260409020610a6590836118c6565b9392505050565b600160005414610a8e5760405162461bcd60e51b815260040161042b90612347565b60026000818155838152600560209081526040808320853584528252918290208251808401845281548152835180850190945260018201546001600160a01b03168452930154828201528201528051610af95760405162461bcd60e51b815260040161042b9061252d565b600082604051602001610b0c919061298d565b60408051601f1981840301815291905282518151602083012091925014610b455760405162461bcd60e51b815260040161042b906129a0565b8260000135847f0563d357b89128d5a0c37c9b06420836e35d193eaf17f7960fc88e47d1e02f57858560200151604051610b809291906129e9565b60405180910390a360405163ee5b48eb60e01b81526005600160991b019063ee5b48eb90610bb2908490600401612a6e565b6020604051808303816000875af1158015610bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf59190612a81565b50506001600055505050565b6001805414610c225760405162461bcd60e51b815260040161042b90612a9a565b60026001556001600160a01b038116610c965760405162461bcd60e51b815260206004820152603060248201527f54656c65706f727465724d657373656e6765723a207a65726f2072656c61796560448201526f7220726577617264206164647265737360801b606482015260840161042b565b6040516306f8253560e41b815263ffffffff8316600482015260009081906005600160991b0190636f82535090602401600060405180830381865afa158015610ce3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d0b9190810190612b3f565b9150915080610d6e5760405162461bcd60e51b815260206004820152602960248201527f54656c65706f727465724d657373656e6765723a20696e76616c69642077617260448201526870206d65737361676560b81b606482015260840161042b565b60208201516001600160a01b03163014610de55760405162461bcd60e51b815260206004820152603260248201527f54656c65706f727465724d657373656e6765723a20696e76616c6964206f726960448201527167696e2073656e646572206164647265737360701b606482015260840161042b565b60025480610e5e576005600160991b016001600160a01b0316634213cf786040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e569190612a81565b600281905590505b60008360400151806020019051810190610e789190612cdc565b905081816040015114610ee75760405162461bcd60e51b815260206004820152603160248201527f54656c65706f727465724d657373656e6765723a20696e76616c6964206465736044820152701d1a5b985d1a5bdb8818da185a5b881251607a1b606482015260840161042b565b8351815160009182526007602090815260408084209284529190529020546001600160a01b031615610f725760405162461bcd60e51b815260206004820152602e60248201527f54656c65706f727465724d657373656e6765723a206d65737361676520616c7260448201526d1958591e4819195b1a5d995c995960921b606482015260840161042b565b610f80338260a0015161198b565b610fde5760405162461bcd60e51b815260206004820152602960248201527f54656c65706f727465724d657373656e6765723a20756e617574686f72697a6560448201526832103932b630bcb2b960b91b606482015260840161042b565b8351600090815260076020908152604080832084518452909152902080546001600160a01b0319166001600160a01b03871617905560e0810151511561102a57835161102a9082611a00565b60c08101515160005b818110156110855760008360c001518281518110611053576110536123a0565b60200260200101519050611074876000015182600001518360200151611b2f565b5061107e816123cc565b9050611033565b5084516000908152600460209081526040918290208251808401909352845183526001600160a01b03891691830191909152906110c3908290611bff565b82518651604051339291907f6b013241f9192863bc66c1f1e9a01dc592c94592bfed5e1ed380808525679575906110fd908c908990612eec565b60405180910390a4505060018055505050505050565b600061088082611c5b565b60008281526007602090815260408083208484529091528120546001600160a01b03161515610a65565b60018054146111695760405162461bcd60e51b815260040161042b90612a9a565b6002600155600082815260066020908152604080832084358452909152902054806111a65760405162461bcd60e51b815260040161042b9061252d565b80826040516020016111b8919061298d565b60405160208183030381529060405280519060200120146111eb5760405162461bcd60e51b815260040161042b906129a0565b60006111fd60808401606085016121ed565b6001600160a01b03163b116112715760405162461bcd60e51b815260206004820152603460248201527f54656c65706f727465724d657373656e6765723a2064657374696e6174696f6e604482015273206164647265737320686173206e6f20636f646560601b606482015260840161042b565b60405182359084907f5ad362d54cba0e49d358be9ce586a7136d10a2533579c4460b7e48ec273083ef90600090a3600083815260066020908152604080832085358452825280832083905585916112cc9186019086016121ed565b6112d960e0860186612f10565b6040516024016112ec9493929190612f56565b60408051601f198184030181529190526020810180516001600160e01b031663643477d560e11b1790529050600061133461132d60808601606087016121ed565b5a84611c75565b9050806113975760405162461bcd60e51b815260206004820152602b60248201527f54656c65706f727465724d657373656e6765723a20726574727920657865637560448201526a1d1a5bdb8819985a5b195960aa1b606482015260840161042b565b505060018055505050565b6000806113b28460000151611c5b565b90506000604051806101000160405280838152602001336001600160a01b031681526020018660000151815260200186602001516001600160a01b0316815260200186606001518152602001866080015181526020018581526020018660a00151815250905060008160405160200161142b9190612f81565b60408051601f198184030181529181528751600090815260036020908152828220879055918901519091015191925090156114a5576040870151516001600160a01b031661148b5760405162461bcd60e51b815260040161042b906124d9565b604087015180516020909101516114a291906115d4565b90505b60408051808201825288820151516001600160a01b03908116825260208083018590528351808501855286518783012081528082018481528c516000908152600584528681208b82528452869020915182555180516001830180546001600160a01b031916919095161790935591015160029091015588519151909186917f0563d357b89128d5a0c37c9b06420836e35d193eaf17f7960fc88e47d1e02f57906115529088908690612f94565b60405180910390a360405163ee5b48eb60e01b81526005600160991b019063ee5b48eb90611584908690600401612a6e565b6020604051808303816000875af11580156115a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c79190612a81565b5093979650505050505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa15801561161d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116419190612a81565b90506116586001600160a01b038516333086611c8f565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561169f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c39190612a81565b90508181116117295760405162461bcd60e51b815260206004820152602c60248201527f5361666545524332305472616e7366657246726f6d3a2062616c616e6365206e60448201526b1bdd081a5b98dc99585cd95960a21b606482015260840161042b565b6117338282612fa7565b95945050505050565b6040516001600160a01b03831660248201526044810182905261179f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611cc7565b505050565b8054600182015460009161088091612fa7565b606060006117ce60056117c9856117a4565b611d99565b90508060000361181d576040805160008082526020820190925290611815565b60408051808201909152600080825260208201528152602001906001900390816117ee5790505b509392505050565b806001600160401b038111156118355761183561238a565b60405190808252806020026020018201604052801561187a57816020015b60408051808201909152600080825260208201528152602001906001900390816118535790505b50915060005b818110156118bf5761189184611daf565b8382815181106118a3576118a36123a0565b6020026020010181905250806118b8906123cc565b9050611880565b5050919050565b60408051808201909152600080825260208201526118e3836117a4565b821061193b5760405162461bcd60e51b815260206004820152602160248201527f5265636569707451756575653a20696e646578206f7574206f6620626f756e646044820152607360f81b606482015260840161042b565b8260020160008385600001546119519190612573565b81526020808201929092526040908101600020815180830190925280548252600101546001600160a01b0316918101919091529392505050565b6000815160000361199e57506001610880565b60005b82518110156119f657836001600160a01b03168382815181106119c6576119c66123a0565b60200260200101516001600160a01b0316036119e6576001915050610880565b6119ef816123cc565b90506119a1565b5060009392505050565b80608001515a1015611a625760405162461bcd60e51b815260206004820152602560248201527f54656c65706f727465724d657373656e6765723a20696e73756666696369656e604482015264742067617360d81b606482015260840161042b565b80606001516001600160a01b03163b600003611a82576109778282611e7a565b602081015160e0820151604051600092611aa0928692602401612fba565b60408051601f198184030181529190526020810180516001600160e01b031663643477d560e11b17905260608301516080840151919250600091611ae5919084611c75565b905080611afc57611af68484611e7a565b50505050565b825160405185907f5ad362d54cba0e49d358be9ce586a7136d10a2533579c4460b7e48ec273083ef90600090a350505050565b60008381526005602090815260408083208584528252918290208251808401845281548152835180850190945260018201546001600160a01b0316845260029091015483830152908101919091528051611b895750505050565b600084815260056020908152604080832086845282528083208381556001810180546001600160a01b031916905560020183905583820180518301516001600160a01b0387811686526008855283862092515116855292528220805491929091611bf4908490612573565b909155505050505050565b6001820180548291600285019160009182611c19836123cc565b90915550815260208082019290925260400160002082518155910151600190910180546001600160a01b0319166001600160a01b039092169190911790555050565b600081815260036020526040812054610880906001612573565b60008060008084516020860160008989f195945050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611af69085906323b872dd60e01b90608401611768565b6000611d1c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611ef89092919063ffffffff16565b80519091501561179f5780806020019051810190611d3a9190612fe4565b61179f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161042b565b6000818310611da85781610a65565b5090919050565b604080518082019091526000808252602082015281546001830154819003611e195760405162461bcd60e51b815260206004820152601960248201527f5265636569707451756575653a20656d70747920717565756500000000000000604482015260640161042b565b60008181526002840160208181526040808420815180830190925280548252600180820180546001600160a01b03811685870152888852959094529490556001600160a01b031990921690559250611e72908290612573565b909255919050565b80604051602001611e8b9190612f81565b60408051601f198184030181528282528051602091820120600086815260068352838120865182529092529190205581519083907fbedbbe6103cef0a6c9ecbf6aa23da414542c42d7918bea18aab8b601b2c3a44990611eec908590612f81565b60405180910390a35050565b6060611f078484600085611f0f565b949350505050565b606082471015611f705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161042b565b600080866001600160a01b03168587604051611f8c9190612fff565b60006040518083038185875af1925050503d8060008114611fc9576040519150601f19603f3d011682016040523d82523d6000602084013e611fce565b606091505b5091509150611fdf87838387611fea565b979650505050505050565b60608315612059578251600003612052576001600160a01b0385163b6120525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161042b565b5081611f07565b611f07838381511561206e5781518083602001fd5b8060405162461bcd60e51b815260040161042b9190612a6e565b60008083601f84011261209a57600080fd5b5081356001600160401b038111156120b157600080fd5b6020830191508360208260051b8501011115610a3257600080fd5b60008060008060008086880360a08112156120e657600080fd5b8735965060208801356001600160401b038082111561210457600080fd5b6121108b838c01612088565b90985096508691506040603f198401121561212a57600080fd5b60408a01955060808a013592508083111561214457600080fd5b505061215289828a01612088565b979a9699509497509295939492505050565b6001600160a01b038116811461217957600080fd5b50565b803561218781612164565b919050565b600080600080608085870312156121a257600080fd5b843593506020850135925060408501356121bb81612164565b9396929550929360600135925050565b600080604083850312156121de57600080fd5b50508035926020909101359150565b6000602082840312156121ff57600080fd5b8135610a6581612164565b60006020828403121561221c57600080fd5b5035919050565b60006020828403121561223557600080fd5b81356001600160401b0381111561224b57600080fd5b820160e08185031215610a6557600080fd5b82815260608101610a65602083018480516001600160a01b03168252602090810151910152565b815181526020808301516001600160a01b03169082015260408101610880565b600080604083850312156122b757600080fd5b8235915060208301356001600160401b038111156122d457600080fd5b830161010081860312156122e757600080fd5b809150509250929050565b6000806040838503121561230557600080fd5b823561231081612164565b915060208301356122e781612164565b6000806040838503121561233357600080fd5b823563ffffffff8116811461231057600080fd5b60208082526023908201527f5265656e7472616e63794775617264733a2073656e646572207265656e7472616040820152626e637960e81b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016123de576123de6123b6565b5060010190565b604080519081016001600160401b03811182821017156124075761240761238a565b60405290565b60405160c081016001600160401b03811182821017156124075761240761238a565b60405161010081016001600160401b03811182821017156124075761240761238a565b604051601f8201601f191681016001600160401b038111828210171561247a5761247a61238a565b604052919050565b60006040828403121561249457600080fd5b61249c6123e5565b905081356124a981612164565b808252506020820135602082015292915050565b6000604082840312156124cf57600080fd5b610a658383612482565b60208082526034908201527f54656c65706f727465724d657373656e6765723a207a65726f2066656520617360408201527373657420636f6e7472616374206164647265737360601b606082015260800190565b60208082526026908201527f54656c65706f727465724d657373656e6765723a206d657373616765206e6f7460408201526508199bdd5b9960d21b606082015260800190565b80820180821115610880576108806123b6565b60006001600160401b0382111561259f5761259f61238a565b5060051b60200190565b600082601f8301126125ba57600080fd5b813560206125cf6125ca83612586565b612452565b82815260059290921b840181019181810190868411156125ee57600080fd5b8286015b8481101561261257803561260581612164565b83529183019183016125f2565b509695505050505050565b60006001600160401b038211156126365761263661238a565b50601f01601f191660200190565b600082601f83011261265557600080fd5b81356126636125ca8261261d565b81815284602083860101111561267857600080fd5b816020850160208301376000918101602001919091529392505050565b600060e082360312156126a757600080fd5b6126af61240d565b823581526126bf6020840161217c565b60208201526126d13660408501612482565b60408201526080830135606082015260a08301356001600160401b03808211156126fa57600080fd5b612706368387016125a9565b608084015260c085013591508082111561271f57600080fd5b5061272c36828601612644565b60a08301525092915050565b6000808335601e1984360301811261274f57600080fd5b83016020810192503590506001600160401b0381111561276e57600080fd5b8060051b3603821315610a3257600080fd5b8183526000602080850194508260005b858110156127be5781356127a381612164565b6001600160a01b031687529582019590820190600101612790565b509495945050505050565b6000808335601e198436030181126127e057600080fd5b83016020810192503590506001600160401b038111156127ff57600080fd5b8060061b3603821315610a3257600080fd5b8183526000602080850194508260005b858110156127be57813587528282013561283a81612164565b6001600160a01b0316878401526040968701969190910190600101612821565b6000808335601e1984360301811261287157600080fd5b83016020810192503590506001600160401b0381111561289057600080fd5b803603821315610a3257600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006101008235845260208301356128df81612164565b6001600160a01b03166020850152604083810135908501526129036060840161217c565b6001600160a01b031660608501526080838101359085015261292860a0840184612738565b8260a087015261293b8387018284612780565b9250505061294c60c08401846127c9565b85830360c087015261295f838284612811565b9250505061297060e084018461285a565b85830360e087015261298383828461289f565b9695505050505050565b602081526000610a6560208301846128c8565b60208082526029908201527f54656c65706f727465724d657373656e6765723a20696e76616c6964206d65736040820152680e6c2ceca40d0c2e6d60bb1b606082015260800190565b6060815260006129fc60608301856128c8565b9050610a65602083018480516001600160a01b03168252602090810151910152565b60005b83811015612a39578181015183820152602001612a21565b50506000910152565b60008151808452612a5a816020860160208601612a1e565b601f01601f19169290920160200192915050565b602081526000610a656020830184612a42565b600060208284031215612a9357600080fd5b5051919050565b60208082526025908201527f5265656e7472616e63794775617264733a207265636569766572207265656e7460408201526472616e637960d81b606082015260800190565b805161218781612164565b600082601f830112612afb57600080fd5b8151612b096125ca8261261d565b818152846020838601011115612b1e57600080fd5b611f07826020830160208701612a1e565b8051801515811461218757600080fd5b60008060408385031215612b5257600080fd5b82516001600160401b0380821115612b6957600080fd5b9084019060608287031215612b7d57600080fd5b604051606081018181108382111715612b9857612b9861238a565b604052825181526020830151612bad81612164565b6020820152604083015182811115612bc457600080fd5b612bd088828601612aea565b6040830152509350612be791505060208401612b2f565b90509250929050565b600082601f830112612c0157600080fd5b81516020612c116125ca83612586565b82815260059290921b84018101918181019086841115612c3057600080fd5b8286015b84811015612612578051612c4781612164565b8352918301918301612c34565b600082601f830112612c6557600080fd5b81516020612c756125ca83612586565b82815260069290921b84018101918181019086841115612c9457600080fd5b8286015b848110156126125760408189031215612cb15760008081fd5b612cb96123e5565b8151815284820151612cca81612164565b81860152835291830191604001612c98565b600060208284031215612cee57600080fd5b81516001600160401b0380821115612d0557600080fd5b908301906101008286031215612d1a57600080fd5b612d2261242f565b82518152612d3260208401612adf565b602082015260408301516040820152612d4d60608401612adf565b60608201526080830151608082015260a083015182811115612d6e57600080fd5b612d7a87828601612bf0565b60a08301525060c083015182811115612d9257600080fd5b612d9e87828601612c54565b60c08301525060e083015182811115612db657600080fd5b612dc287828601612aea565b60e08301525095945050505050565b600081518084526020808501945080840160005b838110156127be5781516001600160a01b031687529582019590820190600101612de5565b600081518084526020808501945080840160005b838110156127be57612e44878351805182526020908101516001600160a01b0316910152565b6040969096019590820190600101612e1e565b60006101008251845260018060a01b036020840151166020850152604083015160408501526060830151612e9660608601826001600160a01b03169052565b506080830151608085015260a08301518160a0860152612eb882860182612dd1565b91505060c083015184820360c0860152612ed28282612e0a565b91505060e083015184820360e08601526117338282612a42565b6001600160a01b0383168152604060208201819052600090611f0790830184612e57565b6000808335601e19843603018112612f2757600080fd5b8301803591506001600160401b03821115612f4157600080fd5b602001915036819003821315610a3257600080fd5b8481526001600160a01b0384166020820152606060408201819052600090612983908301848661289f565b602081526000610a656020830184612e57565b6060815260006129fc6060830185612e57565b81810381811115610880576108806123b6565b8381526001600160a01b038316602082015260606040820181905260009061173390830184612a42565b600060208284031215612ff657600080fd5b610a6582612b2f565b60008251613011818460208701612a1e565b919091019291505056fea26469706673582212204123c01fd7ecf0180c855f50430bd0f6924564a8b55db1b6130eb41adf7a6bee64736f6c63430008120033", + Bin: "0x608060405234801561001057600080fd5b50600160008190558055613051806100296000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c8063892bf412116100b8578063ccb5f8091161007c578063ccb5f80914610366578063d127dc9b14610379578063df20e8bc14610382578063e03555df14610395578063e6e67bd5146103b8578063fc2d6197146103f457600080fd5b8063892bf412146102c1578063af402850146102e1578063b771b3bc146102f4578063c473eef814610302578063c9bb11431461033b57600080fd5b80632bc8b0bf116100ff5780632bc8b0bf146101bd57806333e890fe146101d0578063624488501461021c57806366533d121461022f57806382f2c43a1461028f57600080fd5b8063191eb6981461013c57806319570c7414610162578063220c95681461017757806322296c3a1461018a57806329ec9beb1461019d575b600080fd5b61014f61014a3660046120cc565b610407565b6040519081526020015b60405180910390f35b61017561017036600461218c565b61062a565b005b61014f6101853660046121cb565b610865565b6101756101983660046121ed565b610886565b61014f6101ab36600461220a565b60036020526000908152604090205481565b61014f6101cb36600461220a565b61097b565b6102046101de3660046121cb565b60009182526007602090815260408084209284529190529020546001600160a01b031690565b6040516001600160a01b039091168152602001610159565b61014f61022a366004612223565b610992565b61028161023d3660046121cb565b60056020908152600092835260408084208252918352918190208054825180840190935260018201546001600160a01b031683526002909101549282019290925282565b60405161015992919061225d565b6102a261029d3660046121cb565b6109f0565b604080516001600160a01b039093168352602083019190915201610159565b6102d46102cf3660046121cb565b610a39565b6040516101599190612284565b6101756102ef3660046122a4565b610a6c565b6102046005600160991b0181565b61014f6103103660046122f2565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b61014f6103493660046121cb565b600660209081526000928352604080842090915290825290205481565b610175610374366004612320565b610c01565b61014f60025481565b61014f61039036600461220a565b611113565b6103a86103a33660046121cb565b61111e565b6040519015158152602001610159565b6103df6103c636600461220a565b6004602052600090815260409020805460019091015482565b60408051928352602083019190915201610159565b6101756104023660046122a4565b611148565b60006001600054146104345760405162461bcd60e51b815260040161042b90612347565b60405180910390fd5b60026000908155856001600160401b038111156104535761045361238a565b60405190808252806020026020018201604052801561049857816020015b60408051808201909152600080825260208201528152602001906001900390816104715790505b50905060005b868110156105955760008888838181106104ba576104ba6123a0565b60008d815260076020908152604080832093820295909501358083529290529290922054919250506001600160a01b0316806105475760405162461bcd60e51b815260206004820152602660248201527f54656c65706f727465724d657373656e6765723a2072656365697074206e6f7460448201526508199bdd5b9960d21b606482015260840161042b565b6040518060400160405280838152602001826001600160a01b0316815250848481518110610577576105776123a0565b602002602001018190525050508061058e906123cc565b905061049e565b506040805160c081018252898152600060208201526106199181016105bf368990038901896124bd565b815260200160008152602001868680806020026020016040519081016040528093929190818152602001838360200280828437600092018290525093855250506040805192835260208084019091529092015250826113a2565b600160005598975050505050505050565b60016000541461064c5760405162461bcd60e51b815260040161042b90612347565b6002600055806106b65760405162461bcd60e51b815260206004820152602f60248201527f54656c65706f727465724d657373656e6765723a207a65726f2061646469746960448201526e1bdb985b0819995948185b5bdd5b9d608a1b606482015260840161042b565b6001600160a01b0382166106dc5760405162461bcd60e51b815260040161042b906124d9565b60008481526005602090815260408083208684529091529020546107125760405162461bcd60e51b815260040161042b9061252d565b60008481526005602090815260408083208684529091529020600101546001600160a01b038381169116146107af5760405162461bcd60e51b815260206004820152603760248201527f54656c65706f727465724d657373656e6765723a20696e76616c69642066656560448201527f20617373657420636f6e74726163742061646472657373000000000000000000606482015260840161042b565b60006107bb83836115d4565b60008681526005602090815260408083208884529091528120600201805492935083929091906107ec908490612573565b90915550506000858152600560209081526040808320878452825291829020825160018201546001600160a01b0316815260029091015491810191909152859187917f28fe05eedf0479c9159e5b6dd2a28c93fa1a408eba22dc801fd9bc493a7fc0c2910160405180910390a350506001600055505050565b60008281526005602090815260408083208484529091529020545b92915050565b3360009081526008602090815260408083206001600160a01b0385168452909152902054806109085760405162461bcd60e51b815260206004820152602860248201527f54656c65706f727465724d657373656e6765723a206e6f2072657761726420746044820152676f2072656465656d60c01b606482015260840161042b565b3360008181526008602090815260408083206001600160a01b03871680855290835281842093909355518481529192917f3294c84e5b0f29d9803655319087207bc94f4db29f7927846944822773780b88910160405180910390a36109776001600160a01b038316338361173c565b5050565b6000818152600460205260408120610880906117a4565b60006001600054146109b65760405162461bcd60e51b815260040161042b90612347565b60026000556109e56109c783612695565b833560009081526004602052604090206109e0906117b7565b6113a2565b600160005592915050565b6000828152600560209081526040808320848452825291829020825180840190935260018101546001600160a01b031680845260029091015492909101829052905b9250929050565b60408051808201909152600080825260208201526000838152600460205260409020610a6590836118c6565b9392505050565b600160005414610a8e5760405162461bcd60e51b815260040161042b90612347565b60026000818155838152600560209081526040808320853584528252918290208251808401845281548152835180850190945260018201546001600160a01b03168452930154828201528201528051610af95760405162461bcd60e51b815260040161042b9061252d565b600082604051602001610b0c919061298d565b60408051601f1981840301815291905282518151602083012091925014610b455760405162461bcd60e51b815260040161042b906129a0565b8260000135847f0563d357b89128d5a0c37c9b06420836e35d193eaf17f7960fc88e47d1e02f57858560200151604051610b809291906129e9565b60405180910390a360405163ee5b48eb60e01b81526005600160991b019063ee5b48eb90610bb2908490600401612a6e565b6020604051808303816000875af1158015610bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf59190612a81565b50506001600055505050565b6001805414610c225760405162461bcd60e51b815260040161042b90612a9a565b60026001556001600160a01b038116610c965760405162461bcd60e51b815260206004820152603060248201527f54656c65706f727465724d657373656e6765723a207a65726f2072656c61796560448201526f7220726577617264206164647265737360801b606482015260840161042b565b6040516306f8253560e41b815263ffffffff8316600482015260009081906005600160991b0190636f82535090602401600060405180830381865afa158015610ce3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610d0b9190810190612b3f565b9150915080610d6e5760405162461bcd60e51b815260206004820152602960248201527f54656c65706f727465724d657373656e6765723a20696e76616c69642077617260448201526870206d65737361676560b81b606482015260840161042b565b60208201516001600160a01b03163014610de55760405162461bcd60e51b815260206004820152603260248201527f54656c65706f727465724d657373656e6765723a20696e76616c6964206f726960448201527167696e2073656e646572206164647265737360701b606482015260840161042b565b60025480610e5e576005600160991b016001600160a01b0316634213cf786040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e569190612a81565b600281905590505b60008360400151806020019051810190610e789190612cdc565b905081816040015114610ee75760405162461bcd60e51b815260206004820152603160248201527f54656c65706f727465724d657373656e6765723a20696e76616c6964206465736044820152701d1a5b985d1a5bdb8818da185a5b881251607a1b606482015260840161042b565b8351815160009182526007602090815260408084209284529190529020546001600160a01b031615610f725760405162461bcd60e51b815260206004820152602e60248201527f54656c65706f727465724d657373656e6765723a206d65737361676520616c7260448201526d1958591e4819195b1a5d995c995960921b606482015260840161042b565b610f80338260a0015161198b565b610fde5760405162461bcd60e51b815260206004820152602960248201527f54656c65706f727465724d657373656e6765723a20756e617574686f72697a6560448201526832103932b630bcb2b960b91b606482015260840161042b565b8351600090815260076020908152604080832084518452909152902080546001600160a01b0319166001600160a01b03871617905560e0810151511561102a57835161102a9082611a00565b60c08101515160005b818110156110855760008360c001518281518110611053576110536123a0565b60200260200101519050611074876000015182600001518360200151611b2f565b5061107e816123cc565b9050611033565b5084516000908152600460209081526040918290208251808401909352845183526001600160a01b03891691830191909152906110c3908290611bff565b82518651604051339291907f6b013241f9192863bc66c1f1e9a01dc592c94592bfed5e1ed380808525679575906110fd908c908990612eec565b60405180910390a4505060018055505050505050565b600061088082611c5b565b60008281526007602090815260408083208484529091528120546001600160a01b03161515610a65565b60018054146111695760405162461bcd60e51b815260040161042b90612a9a565b6002600155600082815260066020908152604080832084358452909152902054806111a65760405162461bcd60e51b815260040161042b9061252d565b80826040516020016111b8919061298d565b60405160208183030381529060405280519060200120146111eb5760405162461bcd60e51b815260040161042b906129a0565b60006111fd60808401606085016121ed565b6001600160a01b03163b116112715760405162461bcd60e51b815260206004820152603460248201527f54656c65706f727465724d657373656e6765723a2064657374696e6174696f6e604482015273206164647265737320686173206e6f20636f646560601b606482015260840161042b565b60405182359084907f5ad362d54cba0e49d358be9ce586a7136d10a2533579c4460b7e48ec273083ef90600090a3600083815260066020908152604080832085358452825280832083905585916112cc9186019086016121ed565b6112d960e0860186612f10565b6040516024016112ec9493929190612f56565b60408051601f198184030181529190526020810180516001600160e01b031663643477d560e11b1790529050600061133461132d60808601606087016121ed565b5a84611c75565b9050806113975760405162461bcd60e51b815260206004820152602b60248201527f54656c65706f727465724d657373656e6765723a20726574727920657865637560448201526a1d1a5bdb8819985a5b195960aa1b606482015260840161042b565b505060018055505050565b6000806113b28460000151611c5b565b90506000604051806101000160405280838152602001336001600160a01b031681526020018660000151815260200186602001516001600160a01b0316815260200186606001518152602001866080015181526020018581526020018660a00151815250905060008160405160200161142b9190612f81565b60408051601f198184030181529181528751600090815260036020908152828220879055918901519091015191925090156114a5576040870151516001600160a01b031661148b5760405162461bcd60e51b815260040161042b906124d9565b604087015180516020909101516114a291906115d4565b90505b60408051808201825288820151516001600160a01b03908116825260208083018590528351808501855286518783012081528082018481528c516000908152600584528681208b82528452869020915182555180516001830180546001600160a01b031916919095161790935591015160029091015588519151909186917f0563d357b89128d5a0c37c9b06420836e35d193eaf17f7960fc88e47d1e02f57906115529088908690612f94565b60405180910390a360405163ee5b48eb60e01b81526005600160991b019063ee5b48eb90611584908690600401612a6e565b6020604051808303816000875af11580156115a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115c79190612a81565b5093979650505050505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b038516906370a0823190602401602060405180830381865afa15801561161d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116419190612a81565b90506116586001600160a01b038516333086611c8f565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561169f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c39190612a81565b90508181116117295760405162461bcd60e51b815260206004820152602c60248201527f5361666545524332305472616e7366657246726f6d3a2062616c616e6365206e60448201526b1bdd081a5b98dc99585cd95960a21b606482015260840161042b565b6117338282612fa7565b95945050505050565b6040516001600160a01b03831660248201526044810182905261179f90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611cc7565b505050565b8054600182015460009161088091612fa7565b606060006117ce60056117c9856117a4565b611d99565b90508060000361181d576040805160008082526020820190925290611815565b60408051808201909152600080825260208201528152602001906001900390816117ee5790505b509392505050565b806001600160401b038111156118355761183561238a565b60405190808252806020026020018201604052801561187a57816020015b60408051808201909152600080825260208201528152602001906001900390816118535790505b50915060005b818110156118bf5761189184611daf565b8382815181106118a3576118a36123a0565b6020026020010181905250806118b8906123cc565b9050611880565b5050919050565b60408051808201909152600080825260208201526118e3836117a4565b821061193b5760405162461bcd60e51b815260206004820152602160248201527f5265636569707451756575653a20696e646578206f7574206f6620626f756e646044820152607360f81b606482015260840161042b565b8260020160008385600001546119519190612573565b81526020808201929092526040908101600020815180830190925280548252600101546001600160a01b0316918101919091529392505050565b6000815160000361199e57506001610880565b60005b82518110156119f657836001600160a01b03168382815181106119c6576119c66123a0565b60200260200101516001600160a01b0316036119e6576001915050610880565b6119ef816123cc565b90506119a1565b5060009392505050565b80608001515a1015611a625760405162461bcd60e51b815260206004820152602560248201527f54656c65706f727465724d657373656e6765723a20696e73756666696369656e604482015264742067617360d81b606482015260840161042b565b80606001516001600160a01b03163b600003611a82576109778282611e7a565b602081015160e0820151604051600092611aa0928692602401612fba565b60408051601f198184030181529190526020810180516001600160e01b031663643477d560e11b17905260608301516080840151919250600091611ae5919084611c75565b905080611afc57611af68484611e7a565b50505050565b825160405185907f5ad362d54cba0e49d358be9ce586a7136d10a2533579c4460b7e48ec273083ef90600090a350505050565b60008381526005602090815260408083208584528252918290208251808401845281548152835180850190945260018201546001600160a01b0316845260029091015483830152908101919091528051611b895750505050565b600084815260056020908152604080832086845282528083208381556001810180546001600160a01b031916905560020183905583820180518301516001600160a01b0387811686526008855283862092515116855292528220805491929091611bf4908490612573565b909155505050505050565b6001820180548291600285019160009182611c19836123cc565b90915550815260208082019290925260400160002082518155910151600190910180546001600160a01b0319166001600160a01b039092169190911790555050565b600081815260036020526040812054610880906001612573565b60008060008084516020860160008989f195945050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052611af69085906323b872dd60e01b90608401611768565b6000611d1c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611ef89092919063ffffffff16565b80519091501561179f5780806020019051810190611d3a9190612fe4565b61179f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161042b565b6000818310611da85781610a65565b5090919050565b604080518082019091526000808252602082015281546001830154819003611e195760405162461bcd60e51b815260206004820152601960248201527f5265636569707451756575653a20656d70747920717565756500000000000000604482015260640161042b565b60008181526002840160208181526040808420815180830190925280548252600180820180546001600160a01b03811685870152888852959094529490556001600160a01b031990921690559250611e72908290612573565b909255919050565b80604051602001611e8b9190612f81565b60408051601f198184030181528282528051602091820120600086815260068352838120865182529092529190205581519083907fbedbbe6103cef0a6c9ecbf6aa23da414542c42d7918bea18aab8b601b2c3a44990611eec908590612f81565b60405180910390a35050565b6060611f078484600085611f0f565b949350505050565b606082471015611f705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161042b565b600080866001600160a01b03168587604051611f8c9190612fff565b60006040518083038185875af1925050503d8060008114611fc9576040519150601f19603f3d011682016040523d82523d6000602084013e611fce565b606091505b5091509150611fdf87838387611fea565b979650505050505050565b60608315612059578251600003612052576001600160a01b0385163b6120525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161042b565b5081611f07565b611f07838381511561206e5781518083602001fd5b8060405162461bcd60e51b815260040161042b9190612a6e565b60008083601f84011261209a57600080fd5b5081356001600160401b038111156120b157600080fd5b6020830191508360208260051b8501011115610a3257600080fd5b60008060008060008086880360a08112156120e657600080fd5b8735965060208801356001600160401b038082111561210457600080fd5b6121108b838c01612088565b90985096508691506040603f198401121561212a57600080fd5b60408a01955060808a013592508083111561214457600080fd5b505061215289828a01612088565b979a9699509497509295939492505050565b6001600160a01b038116811461217957600080fd5b50565b803561218781612164565b919050565b600080600080608085870312156121a257600080fd5b843593506020850135925060408501356121bb81612164565b9396929550929360600135925050565b600080604083850312156121de57600080fd5b50508035926020909101359150565b6000602082840312156121ff57600080fd5b8135610a6581612164565b60006020828403121561221c57600080fd5b5035919050565b60006020828403121561223557600080fd5b81356001600160401b0381111561224b57600080fd5b820160e08185031215610a6557600080fd5b82815260608101610a65602083018480516001600160a01b03168252602090810151910152565b815181526020808301516001600160a01b03169082015260408101610880565b600080604083850312156122b757600080fd5b8235915060208301356001600160401b038111156122d457600080fd5b830161010081860312156122e757600080fd5b809150509250929050565b6000806040838503121561230557600080fd5b823561231081612164565b915060208301356122e781612164565b6000806040838503121561233357600080fd5b823563ffffffff8116811461231057600080fd5b60208082526023908201527f5265656e7472616e63794775617264733a2073656e646572207265656e7472616040820152626e637960e81b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016123de576123de6123b6565b5060010190565b604080519081016001600160401b03811182821017156124075761240761238a565b60405290565b60405160c081016001600160401b03811182821017156124075761240761238a565b60405161010081016001600160401b03811182821017156124075761240761238a565b604051601f8201601f191681016001600160401b038111828210171561247a5761247a61238a565b604052919050565b60006040828403121561249457600080fd5b61249c6123e5565b905081356124a981612164565b808252506020820135602082015292915050565b6000604082840312156124cf57600080fd5b610a658383612482565b60208082526034908201527f54656c65706f727465724d657373656e6765723a207a65726f2066656520617360408201527373657420636f6e7472616374206164647265737360601b606082015260800190565b60208082526026908201527f54656c65706f727465724d657373656e6765723a206d657373616765206e6f7460408201526508199bdd5b9960d21b606082015260800190565b80820180821115610880576108806123b6565b60006001600160401b0382111561259f5761259f61238a565b5060051b60200190565b600082601f8301126125ba57600080fd5b813560206125cf6125ca83612586565b612452565b82815260059290921b840181019181810190868411156125ee57600080fd5b8286015b8481101561261257803561260581612164565b83529183019183016125f2565b509695505050505050565b60006001600160401b038211156126365761263661238a565b50601f01601f191660200190565b600082601f83011261265557600080fd5b81356126636125ca8261261d565b81815284602083860101111561267857600080fd5b816020850160208301376000918101602001919091529392505050565b600060e082360312156126a757600080fd5b6126af61240d565b823581526126bf6020840161217c565b60208201526126d13660408501612482565b60408201526080830135606082015260a08301356001600160401b03808211156126fa57600080fd5b612706368387016125a9565b608084015260c085013591508082111561271f57600080fd5b5061272c36828601612644565b60a08301525092915050565b6000808335601e1984360301811261274f57600080fd5b83016020810192503590506001600160401b0381111561276e57600080fd5b8060051b3603821315610a3257600080fd5b8183526000602080850194508260005b858110156127be5781356127a381612164565b6001600160a01b031687529582019590820190600101612790565b509495945050505050565b6000808335601e198436030181126127e057600080fd5b83016020810192503590506001600160401b038111156127ff57600080fd5b8060061b3603821315610a3257600080fd5b8183526000602080850194508260005b858110156127be57813587528282013561283a81612164565b6001600160a01b0316878401526040968701969190910190600101612821565b6000808335601e1984360301811261287157600080fd5b83016020810192503590506001600160401b0381111561289057600080fd5b803603821315610a3257600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006101008235845260208301356128df81612164565b6001600160a01b03166020850152604083810135908501526129036060840161217c565b6001600160a01b031660608501526080838101359085015261292860a0840184612738565b8260a087015261293b8387018284612780565b9250505061294c60c08401846127c9565b85830360c087015261295f838284612811565b9250505061297060e084018461285a565b85830360e087015261298383828461289f565b9695505050505050565b602081526000610a6560208301846128c8565b60208082526029908201527f54656c65706f727465724d657373656e6765723a20696e76616c6964206d65736040820152680e6c2ceca40d0c2e6d60bb1b606082015260800190565b6060815260006129fc60608301856128c8565b9050610a65602083018480516001600160a01b03168252602090810151910152565b60005b83811015612a39578181015183820152602001612a21565b50506000910152565b60008151808452612a5a816020860160208601612a1e565b601f01601f19169290920160200192915050565b602081526000610a656020830184612a42565b600060208284031215612a9357600080fd5b5051919050565b60208082526025908201527f5265656e7472616e63794775617264733a207265636569766572207265656e7460408201526472616e637960d81b606082015260800190565b805161218781612164565b600082601f830112612afb57600080fd5b8151612b096125ca8261261d565b818152846020838601011115612b1e57600080fd5b611f07826020830160208701612a1e565b8051801515811461218757600080fd5b60008060408385031215612b5257600080fd5b82516001600160401b0380821115612b6957600080fd5b9084019060608287031215612b7d57600080fd5b604051606081018181108382111715612b9857612b9861238a565b604052825181526020830151612bad81612164565b6020820152604083015182811115612bc457600080fd5b612bd088828601612aea565b6040830152509350612be791505060208401612b2f565b90509250929050565b600082601f830112612c0157600080fd5b81516020612c116125ca83612586565b82815260059290921b84018101918181019086841115612c3057600080fd5b8286015b84811015612612578051612c4781612164565b8352918301918301612c34565b600082601f830112612c6557600080fd5b81516020612c756125ca83612586565b82815260069290921b84018101918181019086841115612c9457600080fd5b8286015b848110156126125760408189031215612cb15760008081fd5b612cb96123e5565b8151815284820151612cca81612164565b81860152835291830191604001612c98565b600060208284031215612cee57600080fd5b81516001600160401b0380821115612d0557600080fd5b908301906101008286031215612d1a57600080fd5b612d2261242f565b82518152612d3260208401612adf565b602082015260408301516040820152612d4d60608401612adf565b60608201526080830151608082015260a083015182811115612d6e57600080fd5b612d7a87828601612bf0565b60a08301525060c083015182811115612d9257600080fd5b612d9e87828601612c54565b60c08301525060e083015182811115612db657600080fd5b612dc287828601612aea565b60e08301525095945050505050565b600081518084526020808501945080840160005b838110156127be5781516001600160a01b031687529582019590820190600101612de5565b600081518084526020808501945080840160005b838110156127be57612e44878351805182526020908101516001600160a01b0316910152565b6040969096019590820190600101612e1e565b60006101008251845260018060a01b036020840151166020850152604083015160408501526060830151612e9660608601826001600160a01b03169052565b506080830151608085015260a08301518160a0860152612eb882860182612dd1565b91505060c083015184820360c0860152612ed28282612e0a565b91505060e083015184820360e08601526117338282612a42565b6001600160a01b0383168152604060208201819052600090611f0790830184612e57565b6000808335601e19843603018112612f2757600080fd5b8301803591506001600160401b03821115612f4157600080fd5b602001915036819003821315610a3257600080fd5b8481526001600160a01b0384166020820152606060408201819052600090612983908301848661289f565b602081526000610a656020830184612e57565b6060815260006129fc6060830185612e57565b81810381811115610880576108806123b6565b8381526001600160a01b038316602082015260606040820181905260009061173390830184612a42565b600060208284031215612ff657600080fd5b610a6582612b2f565b60008251613011818460208701612a1e565b919091019291505056fea2646970667358221220756e14dcb4a1b16efdce92887b7dd5d846543fed6d7591a4402f58524bfef0e564736f6c63430008120033", } // TeleporterMessengerABI is the input ABI used to generate the binding from. diff --git a/contracts/src/Teleporter/README.md b/contracts/src/Teleporter/README.md index 85e3d20aa..80be51d06 100644 --- a/contracts/src/Teleporter/README.md +++ b/contracts/src/Teleporter/README.md @@ -5,7 +5,9 @@ - [Data Flow](#data-flow) - [Properties](#properties) - [Fees](#fees) + - [Message Receipts and Fee Redemption](#message-receipts-and-fee-redemption) - [Required Interface](#required-interface) + - [Teleporter Contract Deployment](#teleporter-contract-deployment) - [Message Delivery and Execution](#message-delivery-and-execution) @@ -19,6 +21,8 @@ The `ITeleporterMessenger` interface provides two primary methods: The `ITeleporterReceiver` interface provides a single method. All contracts that wish to receive Teleporter messages on the destination chain must implement this interface: - `receiveTeleporterMessage`: called by the Teleporter contract on the destination chain to deliver a message to the destination contract. +> Note: If a contract does not implement `ITeleporterReceiver`, but instead implements [fallback](https://docs.soliditylang.org/en/latest/contracts.html#fallback-function), the fallback function will be called when Teleporter attempts to perform message execution. The message execution is marked as failed if the fallback function reverts, otherwise it is marked as successfully executed. + ## Data Flow
diff --git a/contracts/src/Teleporter/TeleporterMessenger.sol b/contracts/src/Teleporter/TeleporterMessenger.sol index 970ec35f8..8af850cc2 100644 --- a/contracts/src/Teleporter/TeleporterMessenger.sol +++ b/contracts/src/Teleporter/TeleporterMessenger.sol @@ -357,6 +357,8 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards { // Re-encode the payload by ABI encoding a call to the {receiveTeleporterMessage} function // defined by the {ITeleporterReceiver} interface. + // If the destination address does not implement {receiveTeleporterMessage}, but does implement + // a fallback function, then the fallback function will be called instead. bytes memory payload = abi.encodeCall( ITeleporterReceiver.receiveTeleporterMessage, (originBlockchainID, message.senderAddress, message.message) diff --git a/contracts/src/Teleporter/tests/FallbackReceiveTests.t.sol b/contracts/src/Teleporter/tests/FallbackReceiveTests.t.sol new file mode 100644 index 000000000..0c19642ee --- /dev/null +++ b/contracts/src/Teleporter/tests/FallbackReceiveTests.t.sol @@ -0,0 +1,148 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +// SPDX-License-Identifier: Ecosystem + +pragma solidity 0.8.18; + +import { + TeleporterMessengerTest, + TeleporterMessage, + WarpMessage, + TeleporterMessageReceipt +} from "./TeleporterMessengerTest.t.sol"; + +enum FallbackReceiveAction { + Fail, + Succeed +} + +contract FallbackReceiveApp { + bytes32 public originChainID; + address public originSenderAddress; + uint256 public nonce; + + constructor(bytes32 originChainID_, address originSenderAddress_) { + originChainID = originChainID_; + originSenderAddress = originSenderAddress_; + } + + // solhint-disable-next-line no-complex-fallback, payable-fallback + fallback(bytes calldata data) external returns (bytes memory) { + bytes4 selector = bytes4(data[:4]); + // Check that the function selector was for receiveTeleporterMessage. + require( + selector == bytes4(keccak256("receiveTeleporterMessage(bytes32,address,bytes)")), + "FallbackReceiveApp: Invalid selector" + ); + + (bytes32 originChainID_, address originSenderAddress_, bytes memory message) = + abi.decode(data[4:], (bytes32, address, bytes)); + + require(originChainID == originChainID_, "FallbackReceiveApp: Invalid origin chain ID"); + require( + originSenderAddress == originSenderAddress_, + "FallbackReceiveApp: Invalid origin sender address" + ); + + FallbackReceiveAction action = abi.decode(message, (FallbackReceiveAction)); + + if (action == FallbackReceiveAction.Fail) { + require(false, "FallbackReceiveApp: Fallback failed"); + } else if (action == FallbackReceiveAction.Succeed) { + nonce++; + } else { + revert("FallbackReceiveApp: Invalid action"); + } + + return abi.encode(nonce); + } +} + +contract FallbackReceiveTest is TeleporterMessengerTest { + FallbackReceiveApp public destinationContract; + + function setUp() public virtual override { + TeleporterMessengerTest.setUp(); + destinationContract = new FallbackReceiveApp( + DEFAULT_ORIGIN_CHAIN_ID, + address(this) + ); + } + + function testFallbackSuccess() public { + uint256 nonce = destinationContract.nonce(); + + // Construct the mock message to be received. + TeleporterMessage memory messageToReceive = TeleporterMessage({ + messageID: 1, + senderAddress: address(this), + destinationBlockchainID: DEFAULT_DESTINATION_CHAIN_ID, + destinationAddress: address(destinationContract), + requiredGasLimit: DEFAULT_REQUIRED_GAS_LIMIT, + allowedRelayerAddresses: new address[](0), + receipts: new TeleporterMessageReceipt[](0), + message: abi.encode(FallbackReceiveAction.Succeed) + }); + WarpMessage memory warpMessage = + _createDefaultWarpMessage(DEFAULT_ORIGIN_CHAIN_ID, abi.encode(messageToReceive)); + + // Mock the call to the warp precompile to get the message. + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); + + // Receive the message and check that message execution was successful. + vm.expectEmit(true, true, true, true, address(teleporterMessenger)); + emit MessageExecuted(DEFAULT_ORIGIN_CHAIN_ID, messageToReceive.messageID); + vm.expectEmit(true, true, true, true, address(teleporterMessenger)); + emit ReceiveCrossChainMessage( + warpMessage.sourceChainID, + messageToReceive.messageID, + address(this), + DEFAULT_RELAYER_REWARD_ADDRESS, + messageToReceive + ); + teleporterMessenger.receiveCrossChainMessage(0, DEFAULT_RELAYER_REWARD_ADDRESS); + + // Check that the nonce was incremented. + assertEq(destinationContract.nonce(), nonce + 1); + } + + function testFallbackFail() public { + uint256 nonce = destinationContract.nonce(); + + // Construct the mock message to be received. + TeleporterMessage memory messageToReceive = TeleporterMessage({ + messageID: 1, + senderAddress: address(this), + destinationBlockchainID: DEFAULT_DESTINATION_CHAIN_ID, + destinationAddress: address(destinationContract), + requiredGasLimit: DEFAULT_REQUIRED_GAS_LIMIT, + allowedRelayerAddresses: new address[](0), + receipts: new TeleporterMessageReceipt[](0), + message: abi.encode(FallbackReceiveAction.Fail) + }); + WarpMessage memory warpMessage = + _createDefaultWarpMessage(DEFAULT_ORIGIN_CHAIN_ID, abi.encode(messageToReceive)); + + // Mock the call to the warp precompile to get the message. + _setUpSuccessGetVerifiedWarpMessageMock(0, warpMessage); + + // Receive the message and check that message execution was successful. + vm.expectEmit(true, true, true, true, address(teleporterMessenger)); + emit MessageExecutionFailed( + DEFAULT_ORIGIN_CHAIN_ID, messageToReceive.messageID, messageToReceive + ); + vm.expectEmit(true, true, true, true, address(teleporterMessenger)); + emit ReceiveCrossChainMessage( + warpMessage.sourceChainID, + messageToReceive.messageID, + address(this), + DEFAULT_RELAYER_REWARD_ADDRESS, + messageToReceive + ); + teleporterMessenger.receiveCrossChainMessage(0, DEFAULT_RELAYER_REWARD_ADDRESS); + + // Check that the nonce was not changed. + assertEq(destinationContract.nonce(), nonce); + } +}