@layerzerolabs/lz-evm-sdk-v2 3.0.113 → 3.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/artifacts/verification/verification-data-25ddf6a7583f79046cf40a127519d382.json +226 -0
- package/artifacts/{verification-data.json → verification/verification-data-a8863204d99e527a43bf167bfb175e3d.json} +30 -208
- package/artifacts/verification/verification-data-bcbd337ac361c0226ab3df95de084331.json +175 -0
- package/artifacts-tron/verification/verification-data-0aa95d94acbfa5a997361f092b2c3cdb.json +226 -0
- package/artifacts-tron/verification/verification-data-59399a7002f16d8b85f75e0cbced0107.json +220 -0
- package/artifacts-tron/{verification-data.json → verification/verification-data-a5f4488d362c50b6eca4ee196216587a.json} +30 -208
- package/artifacts-tron/verification/verification-data-bbff712af1796cf3cc91235aad448a01.json +97 -0
- package/artifacts-tron/verification/verification-data-f032c27816b48be5fcf3cc7ed3c366c0.json +175 -0
- package/artifacts-zk/verification/verification-data-2436ac350a5ed6bda1e5c836721d5444.json +170 -0
- package/artifacts-zk/{verification-data.json → verification/verification-data-8e3240debec8007ae59598d4a47ea27a.json} +25 -208
- package/artifacts-zk/verification/verification-data-c8fdeec934f86e4f0d4613b885a38d08.json +221 -0
- package/deployments/arbitrum-sandbox-local/DVN.json +1 -1
- package/deployments/arbitrum-sandbox-local/DVNDecompressor.json +1 -1
- package/deployments/arbitrum-sandbox-local/DVNFeeLib.json +1 -1
- package/deployments/arbitrum-sandbox-local/DefaultProxyAdmin.json +1 -1
- package/deployments/arbitrum-sandbox-local/EndpointV2.json +1 -1
- package/deployments/arbitrum-sandbox-local/EndpointV2View.json +1 -1
- package/deployments/arbitrum-sandbox-local/EndpointV2View_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/EndpointV2View_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/Executor.json +1 -1
- package/deployments/arbitrum-sandbox-local/ExecutorDecompressor.json +1 -1
- package/deployments/arbitrum-sandbox-local/ExecutorFeeLib.json +1 -1
- package/deployments/arbitrum-sandbox-local/ExecutorProxyAdmin.json +1 -1
- package/deployments/arbitrum-sandbox-local/Executor_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/Executor_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/LzExecutor.json +1 -1
- package/deployments/arbitrum-sandbox-local/LzExecutor_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/LzExecutor_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/MultiCall.json +1 -1
- package/deployments/arbitrum-sandbox-local/NonceContractMock.json +1 -1
- package/deployments/arbitrum-sandbox-local/PriceFeed.json +1 -1
- package/deployments/arbitrum-sandbox-local/PriceFeedProxyAdmin.json +1 -1
- package/deployments/arbitrum-sandbox-local/PriceFeed_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/PriceFeed_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReadLib1002.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReadLib1002View.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReadLib1002ViewProxyAdmin.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReadLib1002View_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReadLib1002View_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln301.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln301View.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln301View_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln301View_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln302.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln302View.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln302View_Implementation.json +1 -1
- package/deployments/arbitrum-sandbox-local/ReceiveUln302View_Proxy.json +1 -1
- package/deployments/arbitrum-sandbox-local/SendUln301.json +1 -1
- package/deployments/arbitrum-sandbox-local/SendUln302.json +1 -1
- package/deployments/arbitrum-sandbox-local/SimpleMessageLib.json +1 -1
- package/deployments/arbitrum-sandbox-local/Treasury.json +1 -1
- package/deployments/arbitrum-sandbox-local/TreasuryFeeHandler.json +1 -1
- package/deployments/bsc-sandbox-local/DVN.json +1 -1
- package/deployments/bsc-sandbox-local/DVNDecompressor.json +1 -1
- package/deployments/bsc-sandbox-local/DVNFeeLib.json +1 -1
- package/deployments/bsc-sandbox-local/DefaultProxyAdmin.json +1 -1
- package/deployments/bsc-sandbox-local/EndpointV2.json +1 -1
- package/deployments/bsc-sandbox-local/EndpointV2View.json +1 -1
- package/deployments/bsc-sandbox-local/EndpointV2View_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/EndpointV2View_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/Executor.json +1 -1
- package/deployments/bsc-sandbox-local/ExecutorDecompressor.json +1 -1
- package/deployments/bsc-sandbox-local/ExecutorFeeLib.json +1 -1
- package/deployments/bsc-sandbox-local/ExecutorProxyAdmin.json +1 -1
- package/deployments/bsc-sandbox-local/Executor_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/Executor_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/LzExecutor.json +1 -1
- package/deployments/bsc-sandbox-local/LzExecutor_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/LzExecutor_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/MultiCall.json +1 -1
- package/deployments/bsc-sandbox-local/NonceContractMock.json +1 -1
- package/deployments/bsc-sandbox-local/PriceFeed.json +1 -1
- package/deployments/bsc-sandbox-local/PriceFeedProxyAdmin.json +1 -1
- package/deployments/bsc-sandbox-local/PriceFeed_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/PriceFeed_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/ReadLib1002.json +1 -1
- package/deployments/bsc-sandbox-local/ReadLib1002View.json +1 -1
- package/deployments/bsc-sandbox-local/ReadLib1002ViewProxyAdmin.json +1 -1
- package/deployments/bsc-sandbox-local/ReadLib1002View_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/ReadLib1002View_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln301.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln301View.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln301View_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln301View_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln302.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln302View.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln302View_Implementation.json +1 -1
- package/deployments/bsc-sandbox-local/ReceiveUln302View_Proxy.json +1 -1
- package/deployments/bsc-sandbox-local/SendUln301.json +1 -1
- package/deployments/bsc-sandbox-local/SendUln302.json +1 -1
- package/deployments/bsc-sandbox-local/SimpleMessageLib.json +1 -1
- package/deployments/bsc-sandbox-local/Treasury.json +1 -1
- package/deployments/bsc-sandbox-local/TreasuryFeeHandler.json +1 -1
- package/deployments/ethereum-sandbox-local/DVN.json +1 -1
- package/deployments/ethereum-sandbox-local/DVNDecompressor.json +1 -1
- package/deployments/ethereum-sandbox-local/DVNFeeLib.json +1 -1
- package/deployments/ethereum-sandbox-local/DefaultProxyAdmin.json +1 -1
- package/deployments/ethereum-sandbox-local/EndpointV2.json +1 -1
- package/deployments/ethereum-sandbox-local/EndpointV2View.json +1 -1
- package/deployments/ethereum-sandbox-local/EndpointV2View_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/EndpointV2View_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/Executor.json +1 -1
- package/deployments/ethereum-sandbox-local/ExecutorDecompressor.json +1 -1
- package/deployments/ethereum-sandbox-local/ExecutorFeeLib.json +1 -1
- package/deployments/ethereum-sandbox-local/ExecutorProxyAdmin.json +1 -1
- package/deployments/ethereum-sandbox-local/Executor_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/Executor_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/LzExecutor.json +1 -1
- package/deployments/ethereum-sandbox-local/LzExecutor_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/LzExecutor_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/MultiCall.json +1 -1
- package/deployments/ethereum-sandbox-local/NonceContractMock.json +1 -1
- package/deployments/ethereum-sandbox-local/PriceFeed.json +1 -1
- package/deployments/ethereum-sandbox-local/PriceFeedProxyAdmin.json +1 -1
- package/deployments/ethereum-sandbox-local/PriceFeed_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/PriceFeed_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/ReadLib1002.json +1 -1
- package/deployments/ethereum-sandbox-local/ReadLib1002View.json +1 -1
- package/deployments/ethereum-sandbox-local/ReadLib1002ViewProxyAdmin.json +1 -1
- package/deployments/ethereum-sandbox-local/ReadLib1002View_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/ReadLib1002View_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln301.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln301View.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln301View_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln301View_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln302.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln302View.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln302View_Implementation.json +1 -1
- package/deployments/ethereum-sandbox-local/ReceiveUln302View_Proxy.json +1 -1
- package/deployments/ethereum-sandbox-local/SendUln301.json +1 -1
- package/deployments/ethereum-sandbox-local/SendUln302.json +1 -1
- package/deployments/ethereum-sandbox-local/SimpleMessageLib.json +1 -1
- package/deployments/ethereum-sandbox-local/Treasury.json +1 -1
- package/deployments/ethereum-sandbox-local/TreasuryFeeHandler.json +1 -1
- package/deployments/tron-sandbox-local/DVN.json +2 -2
- package/deployments/tron-sandbox-local/DVNDecompressor.json +2 -2
- package/deployments/tron-sandbox-local/DVNFeeLib.json +2 -2
- package/deployments/tron-sandbox-local/DefaultProxyAdmin.json +2 -2
- package/deployments/tron-sandbox-local/EndpointV2.json +2 -2
- package/deployments/tron-sandbox-local/EndpointV2View.json +2 -2
- package/deployments/tron-sandbox-local/EndpointV2View_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/EndpointV2View_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/Executor.json +2 -2
- package/deployments/tron-sandbox-local/ExecutorDecompressor.json +2 -2
- package/deployments/tron-sandbox-local/ExecutorFeeLib.json +2 -2
- package/deployments/tron-sandbox-local/ExecutorProxyAdmin.json +2 -2
- package/deployments/tron-sandbox-local/Executor_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/Executor_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/LzExecutor.json +2 -2
- package/deployments/tron-sandbox-local/LzExecutor_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/LzExecutor_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/MultiCall.json +2 -2
- package/deployments/tron-sandbox-local/NonceContractMock.json +2 -2
- package/deployments/tron-sandbox-local/PriceFeed.json +2 -2
- package/deployments/tron-sandbox-local/PriceFeedProxyAdmin.json +2 -2
- package/deployments/tron-sandbox-local/PriceFeed_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/PriceFeed_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/ReadLib1002.json +2 -2
- package/deployments/tron-sandbox-local/ReadLib1002View.json +2 -2
- package/deployments/tron-sandbox-local/ReadLib1002ViewProxyAdmin.json +2 -2
- package/deployments/tron-sandbox-local/ReadLib1002View_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/ReadLib1002View_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln301.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln301View.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln301View_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln301View_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln302.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln302View.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln302View_Implementation.json +2 -2
- package/deployments/tron-sandbox-local/ReceiveUln302View_Proxy.json +2 -2
- package/deployments/tron-sandbox-local/SendUln301.json +2 -2
- package/deployments/tron-sandbox-local/SendUln302.json +2 -2
- package/deployments/tron-sandbox-local/SimpleMessageLib.json +2 -2
- package/deployments/tron-sandbox-local/Treasury.json +2 -2
- package/deployments/tron-sandbox-local/TreasuryFeeHandler.json +2 -2
- package/package.json +12 -12
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "bbff712af1796cf3cc91235aad448a01",
|
|
3
|
+
"solcLongVersion": "0.8.20+commit.5f1834bc.Emscripten.clang",
|
|
4
|
+
"input": {
|
|
5
|
+
"language": "Solidity",
|
|
6
|
+
"sources": {
|
|
7
|
+
"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol": {
|
|
8
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nimport { IMessageLibManager } from \"./IMessageLibManager.sol\";\nimport { IMessagingComposer } from \"./IMessagingComposer.sol\";\nimport { IMessagingChannel } from \"./IMessagingChannel.sol\";\nimport { IMessagingContext } from \"./IMessagingContext.sol\";\n\nstruct MessagingParams {\n uint32 dstEid;\n bytes32 receiver;\n bytes message;\n bytes options;\n bool payInLzToken;\n}\n\nstruct MessagingReceipt {\n bytes32 guid;\n uint64 nonce;\n MessagingFee fee;\n}\n\nstruct MessagingFee {\n uint256 nativeFee;\n uint256 lzTokenFee;\n}\n\nstruct Origin {\n uint32 srcEid;\n bytes32 sender;\n uint64 nonce;\n}\n\ninterface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {\n event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);\n\n event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);\n\n event PacketDelivered(Origin origin, address receiver);\n\n event LzReceiveAlert(\n address indexed receiver,\n address indexed executor,\n Origin origin,\n bytes32 guid,\n uint256 gas,\n uint256 value,\n bytes message,\n bytes extraData,\n bytes reason\n );\n\n event LzTokenSet(address token);\n\n event DelegateSet(address sender, address delegate);\n\n function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);\n\n function send(\n MessagingParams calldata _params,\n address _refundAddress\n ) external payable returns (MessagingReceipt memory);\n\n function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;\n\n function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);\n\n function initializable(Origin calldata _origin, address _receiver) external view returns (bool);\n\n function lzReceive(\n Origin calldata _origin,\n address _receiver,\n bytes32 _guid,\n bytes calldata _message,\n bytes calldata _extraData\n ) external payable;\n\n // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order\n function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;\n\n function setLzToken(address _lzToken) external;\n\n function lzToken() external view returns (address);\n\n function nativeToken() external view returns (address);\n\n function setDelegate(address _delegate) external;\n}\n"
|
|
9
|
+
},
|
|
10
|
+
"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol": {
|
|
11
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nimport { Origin } from \"./ILayerZeroEndpointV2.sol\";\n\ninterface ILayerZeroReceiver {\n function allowInitializePath(Origin calldata _origin) external view returns (bool);\n\n function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64);\n\n function lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata _message,\n address _executor,\n bytes calldata _extraData\n ) external payable;\n}\n"
|
|
12
|
+
},
|
|
13
|
+
"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol": {
|
|
14
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nstruct SetConfigParam {\n uint32 eid;\n uint32 configType;\n bytes config;\n}\n\ninterface IMessageLibManager {\n struct Timeout {\n address lib;\n uint256 expiry;\n }\n\n event LibraryRegistered(address newLib);\n event DefaultSendLibrarySet(uint32 eid, address newLib);\n event DefaultReceiveLibrarySet(uint32 eid, address newLib);\n event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);\n event SendLibrarySet(address sender, uint32 eid, address newLib);\n event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);\n event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);\n\n function registerLibrary(address _lib) external;\n\n function isRegisteredLibrary(address _lib) external view returns (bool);\n\n function getRegisteredLibraries() external view returns (address[] memory);\n\n function setDefaultSendLibrary(uint32 _eid, address _newLib) external;\n\n function defaultSendLibrary(uint32 _eid) external view returns (address);\n\n function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external;\n\n function defaultReceiveLibrary(uint32 _eid) external view returns (address);\n\n function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;\n\n function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);\n\n function isSupportedEid(uint32 _eid) external view returns (bool);\n\n function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);\n\n /// ------------------- OApp interfaces -------------------\n function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;\n\n function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);\n\n function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);\n\n function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;\n\n function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);\n\n function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external;\n\n function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);\n\n function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;\n\n function getConfig(\n address _oapp,\n address _lib,\n uint32 _eid,\n uint32 _configType\n ) external view returns (bytes memory config);\n}\n"
|
|
15
|
+
},
|
|
16
|
+
"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingChannel.sol": {
|
|
17
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingChannel {\n event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);\n event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);\n event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);\n\n function eid() external view returns (uint32);\n\n // this is an emergency function if a message cannot be verified for some reasons\n // required to provide _nextNonce to avoid race condition\n function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;\n\n function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;\n\n function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;\n\n function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);\n\n function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);\n\n function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);\n\n function inboundPayloadHash(\n address _receiver,\n uint32 _srcEid,\n bytes32 _sender,\n uint64 _nonce\n ) external view returns (bytes32);\n\n function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);\n}\n"
|
|
18
|
+
},
|
|
19
|
+
"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingComposer.sol": {
|
|
20
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingComposer {\n event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);\n event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);\n event LzComposeAlert(\n address indexed from,\n address indexed to,\n address indexed executor,\n bytes32 guid,\n uint16 index,\n uint256 gas,\n uint256 value,\n bytes message,\n bytes extraData,\n bytes reason\n );\n\n function composeQueue(\n address _from,\n address _to,\n bytes32 _guid,\n uint16 _index\n ) external view returns (bytes32 messageHash);\n\n function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;\n\n function lzCompose(\n address _from,\n address _to,\n bytes32 _guid,\n uint16 _index,\n bytes calldata _message,\n bytes calldata _extraData\n ) external payable;\n}\n"
|
|
21
|
+
},
|
|
22
|
+
"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingContext.sol": {
|
|
23
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingContext {\n function isSendingMessage() external view returns (bool);\n\n function getSendContext() external view returns (uint32 dstEid, address sender);\n}\n"
|
|
24
|
+
},
|
|
25
|
+
"@openzeppelin/contracts/access/Ownable.sol": {
|
|
26
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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"
|
|
27
|
+
},
|
|
28
|
+
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
|
|
29
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
|
|
30
|
+
},
|
|
31
|
+
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
|
|
32
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
|
|
33
|
+
},
|
|
34
|
+
"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
|
|
35
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n"
|
|
36
|
+
},
|
|
37
|
+
"@openzeppelin/contracts/utils/Address.sol": {
|
|
38
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 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(errorMessage);\n }\n }\n}\n"
|
|
39
|
+
},
|
|
40
|
+
"@openzeppelin/contracts/utils/Context.sol": {
|
|
41
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\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"
|
|
42
|
+
},
|
|
43
|
+
"contracts/oapp/interfaces/IOAppCore.sol": {
|
|
44
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { ILayerZeroEndpointV2 } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol\";\n\n/**\n * @title IOAppCore\n */\ninterface IOAppCore {\n // Custom error messages\n error OnlyPeer(uint32 eid, bytes32 sender);\n error NoPeer(uint32 eid);\n error InvalidEndpointCall();\n error InvalidDelegate();\n\n // Event emitted when a peer (OApp) is set for a corresponding endpoint\n event PeerSet(uint32 eid, bytes32 peer);\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol contract.\n * @return receiverVersion The version of the OAppReceiver.sol contract.\n */\n function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion);\n\n /**\n * @notice Retrieves the LayerZero endpoint associated with the OApp.\n * @return iEndpoint The LayerZero endpoint as an interface.\n */\n function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint);\n\n /**\n * @notice Retrieves the peer (OApp) associated with a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @return peer The peer address (OApp instance) associated with the corresponding endpoint.\n */\n function peers(uint32 _eid) external view returns (bytes32 peer);\n\n /**\n * @notice Sets the peer address (OApp instance) for a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @param _peer The address of the peer to be associated with the corresponding endpoint.\n */\n function setPeer(uint32 _eid, bytes32 _peer) external;\n\n /**\n * @notice Sets the delegate address for the OApp Core.\n * @param _delegate The address of the delegate to be set.\n */\n function setDelegate(address _delegate) external;\n}\n"
|
|
45
|
+
},
|
|
46
|
+
"contracts/oapp/interfaces/IOAppReceiver.sol": {
|
|
47
|
+
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\nimport { ILayerZeroReceiver, Origin } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol\";\n\ninterface IOAppReceiver is ILayerZeroReceiver {\n /**\n * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint.\n * @param _origin The origin information containing the source endpoint and sender address.\n * - srcEid: The source chain endpoint ID.\n * - sender: The sender address on the src chain.\n * - nonce: The nonce of the message.\n * @param _message The lzReceive payload.\n * @param _sender The sender address.\n * @return isSender Is a valid sender.\n *\n * @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer.\n * @dev The default sender IS the OAppReceiver implementer.\n */\n function isComposeMsgSender(\n Origin calldata _origin,\n bytes calldata _message,\n address _sender\n ) external view returns (bool isSender);\n}\n"
|
|
48
|
+
},
|
|
49
|
+
"contracts/oapp/OApp.sol": {
|
|
50
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\n// @dev Import the 'MessagingFee' and 'MessagingReceipt' so it's exposed to OApp implementers\n// solhint-disable-next-line no-unused-import\nimport { OAppSender, MessagingFee, MessagingReceipt } from \"./OAppSender.sol\";\n// @dev Import the 'Origin' so it's exposed to OApp implementers\n// solhint-disable-next-line no-unused-import\nimport { OAppReceiver, Origin } from \"./OAppReceiver.sol\";\nimport { OAppCore } from \"./OAppCore.sol\";\n\n/**\n * @title OApp\n * @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality.\n */\nabstract contract OApp is OAppSender, OAppReceiver {\n /**\n * @dev Constructor to initialize the OApp with the provided endpoint and owner.\n * @param _endpoint The address of the LOCAL LayerZero endpoint.\n * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.\n */\n constructor(address _endpoint, address _delegate) OAppCore(_endpoint, _delegate) {}\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol implementation.\n * @return receiverVersion The version of the OAppReceiver.sol implementation.\n */\n function oAppVersion()\n public\n pure\n virtual\n override(OAppSender, OAppReceiver)\n returns (uint64 senderVersion, uint64 receiverVersion)\n {\n return (SENDER_VERSION, RECEIVER_VERSION);\n }\n}\n"
|
|
51
|
+
},
|
|
52
|
+
"contracts/oapp/OAppCore.sol": {
|
|
53
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { Ownable } from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport { IOAppCore, ILayerZeroEndpointV2 } from \"./interfaces/IOAppCore.sol\";\n\n/**\n * @title OAppCore\n * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.\n */\nabstract contract OAppCore is IOAppCore, Ownable {\n // The LayerZero endpoint associated with the given OApp\n ILayerZeroEndpointV2 public immutable endpoint;\n\n // Mapping to store peers associated with corresponding endpoints\n mapping(uint32 eid => bytes32 peer) public peers;\n\n /**\n * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.\n * @param _endpoint The address of the LOCAL Layer Zero endpoint.\n * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.\n *\n * @dev The delegate typically should be set as the owner of the contract.\n */\n constructor(address _endpoint, address _delegate) {\n endpoint = ILayerZeroEndpointV2(_endpoint);\n\n if (_delegate == address(0)) revert InvalidDelegate();\n endpoint.setDelegate(_delegate);\n }\n\n /**\n * @notice Sets the peer address (OApp instance) for a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @param _peer The address of the peer to be associated with the corresponding endpoint.\n *\n * @dev Only the owner/admin of the OApp can call this function.\n * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.\n * @dev Set this to bytes32(0) to remove the peer address.\n * @dev Peer is a bytes32 to accommodate non-evm chains.\n */\n function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner {\n _setPeer(_eid, _peer);\n }\n\n /**\n * @notice Sets the peer address (OApp instance) for a corresponding endpoint.\n * @param _eid The endpoint ID.\n * @param _peer The address of the peer to be associated with the corresponding endpoint.\n *\n * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.\n * @dev Set this to bytes32(0) to remove the peer address.\n * @dev Peer is a bytes32 to accommodate non-evm chains.\n */\n function _setPeer(uint32 _eid, bytes32 _peer) internal virtual {\n peers[_eid] = _peer;\n emit PeerSet(_eid, _peer);\n }\n\n /**\n * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set.\n * ie. the peer is set to bytes32(0).\n * @param _eid The endpoint ID.\n * @return peer The address of the peer associated with the specified endpoint.\n */\n function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) {\n bytes32 peer = peers[_eid];\n if (peer == bytes32(0)) revert NoPeer(_eid);\n return peer;\n }\n\n /**\n * @notice Sets the delegate address for the OApp.\n * @param _delegate The address of the delegate to be set.\n *\n * @dev Only the owner/admin of the OApp can call this function.\n * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.\n */\n function setDelegate(address _delegate) public onlyOwner {\n endpoint.setDelegate(_delegate);\n }\n}\n"
|
|
54
|
+
},
|
|
55
|
+
"contracts/oapp/OAppReceiver.sol": {
|
|
56
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { IOAppReceiver, Origin } from \"./interfaces/IOAppReceiver.sol\";\nimport { OAppCore } from \"./OAppCore.sol\";\n\n/**\n * @title OAppReceiver\n * @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers.\n */\nabstract contract OAppReceiver is IOAppReceiver, OAppCore {\n // Custom error message for when the caller is not the registered endpoint/\n error OnlyEndpoint(address addr);\n\n // @dev The version of the OAppReceiver implementation.\n // @dev Version is bumped when changes are made to this contract.\n uint64 internal constant RECEIVER_VERSION = 2;\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol contract.\n * @return receiverVersion The version of the OAppReceiver.sol contract.\n *\n * @dev Providing 0 as the default for OAppSender version. Indicates that the OAppSender is not implemented.\n * ie. this is a RECEIVE only OApp.\n * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions.\n */\n function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {\n return (0, RECEIVER_VERSION);\n }\n\n /**\n * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint.\n * @dev _origin The origin information containing the source endpoint and sender address.\n * - srcEid: The source chain endpoint ID.\n * - sender: The sender address on the src chain.\n * - nonce: The nonce of the message.\n * @dev _message The lzReceive payload.\n * @param _sender The sender address.\n * @return isSender Is a valid sender.\n *\n * @dev Applications can optionally choose to implement separate composeMsg senders that are NOT the bridging layer.\n * @dev The default sender IS the OAppReceiver implementer.\n */\n function isComposeMsgSender(\n Origin calldata /*_origin*/,\n bytes calldata /*_message*/,\n address _sender\n ) public view virtual returns (bool) {\n return _sender == address(this);\n }\n\n /**\n * @notice Checks if the path initialization is allowed based on the provided origin.\n * @param origin The origin information containing the source endpoint and sender address.\n * @return Whether the path has been initialized.\n *\n * @dev This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received.\n * @dev This defaults to assuming if a peer has been set, its initialized.\n * Can be overridden by the OApp if there is other logic to determine this.\n */\n function allowInitializePath(Origin calldata origin) public view virtual returns (bool) {\n return peers[origin.srcEid] == origin.sender;\n }\n\n /**\n * @notice Retrieves the next nonce for a given source endpoint and sender address.\n * @dev _srcEid The source endpoint ID.\n * @dev _sender The sender address.\n * @return nonce The next nonce.\n *\n * @dev The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement.\n * @dev Is required by the off-chain executor to determine the OApp expects msg execution is ordered.\n * @dev This is also enforced by the OApp.\n * @dev By default this is NOT enabled. ie. nextNonce is hardcoded to return 0.\n */\n function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) public view virtual returns (uint64 nonce) {\n return 0;\n }\n\n /**\n * @dev Entry point for receiving messages or packets from the endpoint.\n * @param _origin The origin information containing the source endpoint and sender address.\n * - srcEid: The source chain endpoint ID.\n * - sender: The sender address on the src chain.\n * - nonce: The nonce of the message.\n * @param _guid The unique identifier for the received LayerZero message.\n * @param _message The payload of the received message.\n * @param _executor The address of the executor for the received message.\n * @param _extraData Additional arbitrary data provided by the corresponding executor.\n *\n * @dev Entry point for receiving msg/packet from the LayerZero endpoint.\n */\n function lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata _message,\n address _executor,\n bytes calldata _extraData\n ) public payable virtual {\n // Ensures that only the endpoint can attempt to lzReceive() messages to this OApp.\n if (address(endpoint) != msg.sender) revert OnlyEndpoint(msg.sender);\n\n // Ensure that the sender matches the expected peer for the source endpoint.\n if (_getPeerOrRevert(_origin.srcEid) != _origin.sender) revert OnlyPeer(_origin.srcEid, _origin.sender);\n\n // Call the internal OApp implementation of lzReceive.\n _lzReceive(_origin, _guid, _message, _executor, _extraData);\n }\n\n /**\n * @dev Internal function to implement lzReceive logic without needing to copy the basic parameter validation.\n */\n function _lzReceive(\n Origin calldata _origin,\n bytes32 _guid,\n bytes calldata _message,\n address _executor,\n bytes calldata _extraData\n ) internal virtual;\n}\n"
|
|
57
|
+
},
|
|
58
|
+
"contracts/oapp/OAppSender.sol": {
|
|
59
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\nimport { SafeERC20, IERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { MessagingParams, MessagingFee, MessagingReceipt } from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol\";\nimport { OAppCore } from \"./OAppCore.sol\";\n\n/**\n * @title OAppSender\n * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.\n */\nabstract contract OAppSender is OAppCore {\n using SafeERC20 for IERC20;\n\n // Custom error messages\n error NotEnoughNative(uint256 msgValue);\n error LzTokenUnavailable();\n\n // @dev The version of the OAppSender implementation.\n // @dev Version is bumped when changes are made to this contract.\n uint64 internal constant SENDER_VERSION = 1;\n\n /**\n * @notice Retrieves the OApp version information.\n * @return senderVersion The version of the OAppSender.sol contract.\n * @return receiverVersion The version of the OAppReceiver.sol contract.\n *\n * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented.\n * ie. this is a SEND only OApp.\n * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions\n */\n function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {\n return (SENDER_VERSION, 0);\n }\n\n /**\n * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation.\n * @param _dstEid The destination endpoint ID.\n * @param _message The message payload.\n * @param _options Additional options for the message.\n * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens.\n * @return fee The calculated MessagingFee for the message.\n * - nativeFee: The native fee for the message.\n * - lzTokenFee: The LZ token fee for the message.\n */\n function _quote(\n uint32 _dstEid,\n bytes memory _message,\n bytes memory _options,\n bool _payInLzToken\n ) internal view virtual returns (MessagingFee memory fee) {\n return\n endpoint.quote(\n MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken),\n address(this)\n );\n }\n\n /**\n * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.\n * @param _dstEid The destination endpoint ID.\n * @param _message The message payload.\n * @param _options Additional options for the message.\n * @param _fee The calculated LayerZero fee for the message.\n * - nativeFee: The native fee.\n * - lzTokenFee: The lzToken fee.\n * @param _refundAddress The address to receive any excess fee values sent to the endpoint.\n * @return receipt The receipt for the sent message.\n * - guid: The unique identifier for the sent message.\n * - nonce: The nonce of the sent message.\n * - fee: The LayerZero fee incurred for the message.\n */\n function _lzSend(\n uint32 _dstEid,\n bytes memory _message,\n bytes memory _options,\n MessagingFee memory _fee,\n address _refundAddress\n ) internal virtual returns (MessagingReceipt memory receipt) {\n // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint.\n uint256 messageValue = _payNative(_fee.nativeFee);\n if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee);\n\n return\n // solhint-disable-next-line check-send-result\n endpoint.send{ value: messageValue }(\n MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0),\n _refundAddress\n );\n }\n\n /**\n * @dev Internal function to pay the native fee associated with the message.\n * @param _nativeFee The native fee to be paid.\n * @return nativeFee The amount of native currency paid.\n *\n * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction,\n * this will need to be overridden because msg.value would contain multiple lzFees.\n * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency.\n * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees.\n * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.\n */\n function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) {\n if (msg.value != _nativeFee) revert NotEnoughNative(msg.value);\n return _nativeFee;\n }\n\n /**\n * @dev Internal function to pay the LZ token fee associated with the message.\n * @param _lzTokenFee The LZ token fee to be paid.\n *\n * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint.\n * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend().\n */\n function _payLzToken(uint256 _lzTokenFee) internal virtual {\n // @dev Cannot cache the token because it is not immutable in the endpoint.\n address lzToken = endpoint.lzToken();\n if (lzToken == address(0)) revert LzTokenUnavailable();\n\n // Pay LZ token fee by sending tokens to the endpoint.\n IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee);\n }\n}\n"
|
|
60
|
+
},
|
|
61
|
+
"contracts/oapp/utils/RateLimiter.sol": {
|
|
62
|
+
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title RateLimiter\n * @dev Abstract contract for implementing rate limiting functionality. This contract provides a basic framework for\n * rate limiting how often a function can be executed. It is designed to be inherited by other contracts requiring rate\n * limiting capabilities to protect resources or services from excessive use.\n *\n * Example 1: Max rate limit reached at beginning of window. As time continues the amount of in flights comes down.\n *\n * Rate Limit Config:\n * limit: 100 units\n * window: 60 seconds\n *\n * Amount in Flight (units) vs. Time Graph (seconds)\n *\n * 100 | * - (Max limit reached at beginning of window)\n * | *\n * | *\n * | *\n * 50 | * (After 30 seconds only 50 units in flight)\n * | *\n * | *\n * | *\n * 0 +--|---|---|---|---|-->(After 60 seconds 0 units are in flight)\n * 0 15 30 45 60 (seconds)\n *\n * Example 2: Max rate limit reached at beginning of window. As time continues the amount of in flights comes down\n * allowing for more to be sent. At the 90 second mark, more in flights come in.\n *\n * Rate Limit Config:\n * limit: 100 units\n * window: 60 seconds\n *\n * Amount in Flight (units) vs. Time Graph (seconds)\n *\n * 100 | * - (Max limit reached at beginning of window)\n * | *\n * | *\n * | *\n * 50 | * * (50 inflight)\n * | * *\n * | * *\n * | * *\n * 0 +--|--|--|--|--|--|--|--|--|--> Time\n * 0 15 30 45 60 75 90 105 120 (seconds)\n *\n * Example 3: Max rate limit reached at beginning of window. At the 15 second mark, the window gets updated to 60\n * seconds and the limit gets updated to 50 units. This scenario shows the direct depiction of \"in flight\" from the\n * previous window affecting the current window.\n *\n * Initial Rate Limit Config: For first 15 seconds\n * limit: 100 units\n * window: 30 seconds\n *\n * Updated Rate Limit Config: Updated at 15 second mark\n * limit: 50 units\n * window: 60 seconds\n *\n * Amount in Flight (units) vs. Time Graph (seconds)\n * 100 - *\n * |*\n * | *\n * | *\n * | *\n * | *\n * | *\n * 75 - | *\n * | *\n * | *\n * | *\n * | *\n * | *\n * | *\n * | *\n * 50 - | 𐫰 <--(Slope changes at the 15 second mark because of the update.\n * | ✧ * Window extended to 60 seconds and limit reduced to 50 units.\n * | ✧ ︎ * Because amountInFlight/lastUpdated do not reset, 50 units are\n * | ✧ * considered in flight from the previous window and the corresponding\n * | ✧ ︎ * decay from the previous rate.)\n * | ✧ *\n * 25 - | ✧ *\n * | ✧ *\n * | ✧ *\n * | ✧ *\n * | ✧ *\n * | ✧ *\n * | ✧ *\n * | ✧ *\n * 0 - +---|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----> Time\n * 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 (seconds)\n * [ Initial 30 Second Window ]\n * [ --------------- Extended 60 Second Window --------------- ]\n */\nabstract contract RateLimiter {\n /**\n * @notice Rate Limit struct.\n * @param amountInFlight The amount in the current window.\n * @param lastUpdated Timestamp representing the last time the rate limit was checked or updated.\n * @param limit This represents the maximum allowed amount within a given window.\n * @param window Defines the duration of the rate limiting window.\n */\n struct RateLimit {\n uint256 amountInFlight;\n uint256 lastUpdated;\n uint256 limit;\n uint256 window;\n }\n\n /**\n * @notice Rate Limit Configuration struct.\n * @param dstEid The destination endpoint id.\n * @param limit This represents the maximum allowed amount within a given window.\n * @param window Defines the duration of the rate limiting window.\n */\n struct RateLimitConfig {\n uint32 dstEid;\n uint256 limit;\n uint256 window;\n }\n\n /**\n * @dev Mapping from destination endpoint id to RateLimit Configurations.\n */\n mapping(uint32 dstEid => RateLimit limit) public rateLimits;\n\n /**\n * @notice Emitted when _setRateLimits occurs.\n * @param rateLimitConfigs An array of `RateLimitConfig` structs representing the rate limit configurations set.\n * - `dstEid`: The destination endpoint id.\n * - `limit`: This represents the maximum allowed amount within a given window.\n * - `window`: Defines the duration of the rate limiting window.\n */\n event RateLimitsChanged(RateLimitConfig[] rateLimitConfigs);\n\n /**\n * @notice Error that is thrown when an amount exceeds the rate_limit.\n */\n error RateLimitExceeded();\n\n /**\n * @notice Get the current amount that can be sent to this destination endpoint id for the given rate limit window.\n * @param _dstEid The destination endpoint id.\n * @return currentAmountInFlight The current amount that was sent.\n * @return amountCanBeSent The amount that can be sent.\n */\n function getAmountCanBeSent(\n uint32 _dstEid\n ) external view virtual returns (uint256 currentAmountInFlight, uint256 amountCanBeSent) {\n RateLimit memory rl = rateLimits[_dstEid];\n return _amountCanBeSent(rl.amountInFlight, rl.lastUpdated, rl.limit, rl.window);\n }\n\n /**\n * @notice Sets the Rate Limit.\n * @param _rateLimitConfigs A `RateLimitConfig` struct representing the rate limit configuration.\n * - `dstEid`: The destination endpoint id.\n * - `limit`: This represents the maximum allowed amount within a given window.\n * - `window`: Defines the duration of the rate limiting window.\n */\n function _setRateLimits(RateLimitConfig[] memory _rateLimitConfigs) internal virtual {\n unchecked {\n for (uint256 i = 0; i < _rateLimitConfigs.length; i++) {\n RateLimit storage rl = rateLimits[_rateLimitConfigs[i].dstEid];\n\n // @dev Ensure we checkpoint the existing rate limit as to not retroactively apply the new decay rate.\n _checkAndUpdateRateLimit(_rateLimitConfigs[i].dstEid, 0);\n\n // @dev Does NOT reset the amountInFlight/lastUpdated of an existing rate limit.\n rl.limit = _rateLimitConfigs[i].limit;\n rl.window = _rateLimitConfigs[i].window;\n }\n }\n emit RateLimitsChanged(_rateLimitConfigs);\n }\n\n /**\n * @notice Checks current amount in flight and amount that can be sent for a given rate limit window.\n * @param _amountInFlight The amount in the current window.\n * @param _lastUpdated Timestamp representing the last time the rate limit was checked or updated.\n * @param _limit This represents the maximum allowed amount within a given window.\n * @param _window Defines the duration of the rate limiting window.\n * @return currentAmountInFlight The amount in the current window.\n * @return amountCanBeSent The amount that can be sent.\n */\n function _amountCanBeSent(\n uint256 _amountInFlight,\n uint256 _lastUpdated,\n uint256 _limit,\n uint256 _window\n ) internal view virtual returns (uint256 currentAmountInFlight, uint256 amountCanBeSent) {\n uint256 timeSinceLastDeposit = block.timestamp - _lastUpdated;\n if (timeSinceLastDeposit >= _window) {\n currentAmountInFlight = 0;\n amountCanBeSent = _limit;\n } else {\n // @dev Presumes linear decay.\n uint256 decay = (_limit * timeSinceLastDeposit) / _window;\n currentAmountInFlight = _amountInFlight <= decay ? 0 : _amountInFlight - decay;\n // @dev In the event the _limit is lowered, and the 'in-flight' amount is higher than the _limit, set to 0.\n amountCanBeSent = _limit <= currentAmountInFlight ? 0 : _limit - currentAmountInFlight;\n }\n }\n\n /**\n * @notice Verifies whether the specified amount falls within the rate limit constraints for the targeted\n * endpoint ID. On successful verification, it updates amountInFlight and lastUpdated. If the amount exceeds\n * the rate limit, the operation reverts.\n * @param _dstEid The destination endpoint id.\n * @param _amount The amount to check for rate limit constraints.\n */\n function _checkAndUpdateRateLimit(uint32 _dstEid, uint256 _amount) internal virtual {\n // @dev By default dstEid that have not been explicitly set will return amountCanBeSent == 0.\n RateLimit storage rl = rateLimits[_dstEid];\n\n (uint256 currentAmountInFlight, uint256 amountCanBeSent) = _amountCanBeSent(\n rl.amountInFlight,\n rl.lastUpdated,\n rl.limit,\n rl.window\n );\n if (_amount > amountCanBeSent) revert RateLimitExceeded();\n\n // @dev Update the storage to contain the new amount and current timestamp.\n rl.amountInFlight = currentAmountInFlight + _amount;\n rl.lastUpdated = block.timestamp;\n }\n}\n"
|
|
63
|
+
},
|
|
64
|
+
"contracts/oft/OFTPrecrime.sol": {
|
|
65
|
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.20;\n\n// import { IOApp } from \"../../interfaces/IOApp.sol\";\n// import { IOFT } from \"./interfaces/IOFT.sol\";\n// import { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n// import { OFTAdapter } from \"./OFTAdapter.sol\";\n\n//contract OFTPreCrime is PreCrime {\n// address public oft;\n// uint256 public EXPECTED_GLOBAL_SUPPLY;\n//\n// constructor(address _endpoint, address _oft) PreCrime(_endpoint) {\n// oft = _oft;\n// }\n//\n// struct SimulationResult {\n// uint256 totalSupplyLD;\n// bool isAdapter;\n// }\n//\n// // @dev only necessary when its exclusive 'OFT', NOT 'OFTAdapter' type\n// // sum of all tokens in the oft network, it can change, but this will need to be updated for pre-Crime to pass\n// function setGlobalSupply(uint256 _globalSupply) public onlyPreCrimeAdmin {\n// EXPECTED_GLOBAL_SUPPLY = _globalSupply;\n// }\n//\n// // -------------------------------\n// // PreCrime\n// function _receiver() internal view override returns (address) {\n// return address(oft);\n// }\n//\n// function _preCrime(bytes[] memory _simulation) internal view override returns (uint16 code, bytes memory reason) {\n// uint256 globalSupply;\n// uint256 expectedGlobalSupply = EXPECTED_GLOBAL_SUPPLY;\n//\n// // @dev indicates that there is an 'OFTAdapter' on one of the chains, not necessarily this local chain\n// bool isOFTAdapter;\n//\n// for (uint256 i = 0; i < _simulation.length; i++) {\n// SimulationResult memory result = abi.decode(_simulation[i], (SimulationResult));\n//\n// if (result.isAdapter) {\n// // @dev does not support multiple' 'OFTAdapter' contracts for a given oft mesh\n// if (isOFTAdapter) return (CODE_PRECRIME_FAILURE, \"OFTPreCrime: multiple OFTAdapters found\");\n// isOFTAdapter = true;\n//\n// expectedGlobalSupply = result.totalSupplyLD;\n// } else {\n// globalSupply += result.totalSupplyLD;\n// }\n// }\n//\n// if (isOFTAdapter && globalSupply > expectedGlobalSupply) {\n// // @dev expectedGlobal supply for an 'OFTAdapter' can be slightly higher due to users sending tokens direct\n// // to the OFTAdapter contract, cant check explicitly \"==\"\n// return (CODE_PRECRIME_FAILURE, \"OFTPreCrime: globalSupply > expectedGlobalSupply\");\n// } else if (globalSupply != expectedGlobalSupply) {\n// // @dev exclusively 'OFT', NOT 'OFTAdapter' instances, balances should be exactly \"==\"\n// return (CODE_PRECRIME_FAILURE, \"OFTPreCrime: globalSupply != expectedGlobalSupply\");\n// } else {\n// return (CODE_SUCCESS, \"\");\n// }\n// }\n//\n// function simulationCallback() external view override returns (bytes memory result) {\n// address token = IOFT(oft).token();\n//\n// // @dev checks if the corresponding _oft on this chain is an adapter version, or returns false if its regular 'OFT'\n// // eg. 'OFTAdapter' lock/unlock tokens from an external token contract, vs. regular 'OFT' mints/burns\n// bool isAdapter = token != oft;\n//\n// // @dev for 'OFTAdapter' the total supply is the total amount locked, otherwise its the totalSupply of oft tokens on the chain\n// uint256 totalSupply = isAdapter ? IERC20(token).balanceOf(oft) : IERC20(oft).totalSupply();\n//\n// return abi.encode(SimulationResult(totalSupply, isAdapter));\n// }\n//\n// function _simulate(Packet[] calldata _packets) internal override returns (uint16 code, bytes memory simulation) {\n// (bool success, bytes memory result) = oft.call{value: msg.value}(\n// abi.encodeWithSelector(IOApp.lzReceiveAndRevert.selector, _packets)\n// );\n// require(!success, \"OFTPreCrime: simulationCallback should be called via revert\");\n//\n// (, result) = _parseRevertResult(result, LzReceiveRevert.selector);\n// return (CODE_SUCCESS, result);\n// }\n//\n// // @dev need to ensure that all preCrimePeers are present inside of the results passed into _checkResultsCompleteness()\n// // when checking oft preCrime we always want every simulation/result from the remote peers\n// function _getPreCrimePeers(\n// Packet[] calldata /*_packets*/\n// ) internal view override returns (uint32[] memory eids, bytes32[] memory peers) {\n// // @dev assumes that the preCrimeEids is the full list of oft eids for this oft mesh\n// return (preCrimeEids, preCrimePeers);\n// }\n//}\n"
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"settings": {
|
|
69
|
+
"optimizer": {
|
|
70
|
+
"enabled": true,
|
|
71
|
+
"runs": 20000
|
|
72
|
+
},
|
|
73
|
+
"evmVersion": "paris",
|
|
74
|
+
"outputSelection": {
|
|
75
|
+
"*": {
|
|
76
|
+
"*": [
|
|
77
|
+
"abi",
|
|
78
|
+
"evm.bytecode",
|
|
79
|
+
"evm.deployedBytecode",
|
|
80
|
+
"evm.methodIdentifiers",
|
|
81
|
+
"metadata",
|
|
82
|
+
"devdoc",
|
|
83
|
+
"userdoc",
|
|
84
|
+
"storageLayout",
|
|
85
|
+
"evm.gasEstimates"
|
|
86
|
+
],
|
|
87
|
+
"": [
|
|
88
|
+
"ast"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"metadata": {
|
|
93
|
+
"useLiteralContent": true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|