@hyperlane-xyz/helloworld 1.0.0-beta5 → 1.0.0-beta8
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/contracts/HelloWorld.sol +4 -1
- package/contracts/flattened.sol +2593 -0
- package/dist/hardhat.config.d.ts +6 -0
- package/dist/hardhat.config.d.ts.map +1 -0
- package/dist/hardhat.config.js +28 -0
- package/dist/hardhat.config.js.map +1 -0
- package/dist/src/app/app.d.ts +18 -0
- package/dist/src/app/app.d.ts.map +1 -0
- package/dist/src/app/app.js +75 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/contracts.d.ts +6 -0
- package/dist/src/app/contracts.d.ts.map +1 -0
- package/dist/src/app/contracts.js +8 -0
- package/dist/src/app/contracts.js.map +1 -0
- package/dist/src/deploy/check.d.ts +7 -0
- package/dist/src/deploy/check.d.ts.map +1 -0
- package/dist/src/deploy/check.js +8 -0
- package/dist/src/deploy/check.js.map +1 -0
- package/dist/src/deploy/config.d.ts +6 -0
- package/dist/src/deploy/config.d.ts.map +1 -0
- package/dist/src/deploy/config.js +9 -0
- package/dist/src/deploy/config.js.map +1 -0
- package/dist/src/deploy/deploy.d.ts +11 -0
- package/dist/src/deploy/deploy.d.ts.map +1 -0
- package/dist/src/deploy/deploy.js +35 -0
- package/dist/src/deploy/deploy.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +36 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scripts/check.d.ts +2 -0
- package/dist/src/scripts/check.d.ts.map +1 -0
- package/dist/src/scripts/check.js +43 -0
- package/dist/src/scripts/check.js.map +1 -0
- package/dist/src/scripts/deploy.d.ts +2 -0
- package/dist/src/scripts/deploy.d.ts.map +1 -0
- package/dist/src/scripts/deploy.js +35 -0
- package/dist/src/scripts/deploy.js.map +1 -0
- package/dist/src/test/deploy.test.d.ts +2 -0
- package/dist/src/test/deploy.test.d.ts.map +1 -0
- package/dist/src/test/deploy.test.js +47 -0
- package/dist/src/test/deploy.test.js.map +1 -0
- package/dist/src/test/helloworld.test.d.ts +2 -0
- package/dist/src/test/helloworld.test.d.ts.map +1 -0
- package/dist/src/test/helloworld.test.js +65 -0
- package/dist/src/test/helloworld.test.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient.d.ts +202 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/Router.d.ts +279 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/Router.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/Router.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/Router.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/index.d.ts +3 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/index.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/index.js +3 -0
- package/dist/src/types/@hyperlane-xyz/core/contracts/index.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/index.d.ts +5 -0
- package/dist/src/types/@hyperlane-xyz/core/index.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/index.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/index.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster.d.ts +51 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule.d.ts +59 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule.d.ts +43 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.d.ts +3 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.js +3 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMailbox.d.ts +107 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMailbox.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMailbox.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMailbox.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMessageRecipient.d.ts +51 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMessageRecipient.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMessageRecipient.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/IMessageRecipient.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/index.d.ts +6 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/index.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/index.js +4 -0
- package/dist/src/types/@hyperlane-xyz/core/interfaces/index.js.map +1 -0
- package/dist/src/types/@hyperlane-xyz/index.d.ts +3 -0
- package/dist/src/types/@hyperlane-xyz/index.d.ts.map +1 -0
- package/dist/src/types/@hyperlane-xyz/index.js +4 -0
- package/dist/src/types/@hyperlane-xyz/index.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.d.ts +99 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.js +4 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/index.d.ts +2 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/index.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/index.js +3 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/access/index.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/index.d.ts +7 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/index.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/index.js +4 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/index.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/index.d.ts +3 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/index.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/index.js +4 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/index.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.d.ts +40 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.js +4 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts +2 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/index.js +3 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/proxy/utils/index.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.d.ts +40 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.js +4 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.js.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/index.d.ts +2 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/index.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/index.js +3 -0
- package/dist/src/types/@openzeppelin/contracts-upgradeable/utils/index.js.map +1 -0
- package/dist/src/types/@openzeppelin/index.d.ts +3 -0
- package/dist/src/types/@openzeppelin/index.d.ts.map +1 -0
- package/dist/src/types/@openzeppelin/index.js +4 -0
- package/dist/src/types/@openzeppelin/index.js.map +1 -0
- package/dist/src/types/common.d.ts +22 -0
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/src/types/common.js +4 -0
- package/dist/src/types/common.js.map +1 -0
- package/dist/src/types/contracts/HelloWorld.d.ts +359 -0
- package/dist/src/types/contracts/HelloWorld.d.ts.map +1 -0
- package/dist/src/types/contracts/HelloWorld.js +4 -0
- package/dist/src/types/contracts/HelloWorld.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/ContextUpgradeable.d.ts +40 -0
- package/dist/src/types/contracts/flattened.sol/ContextUpgradeable.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/ContextUpgradeable.js +4 -0
- package/dist/src/types/contracts/flattened.sol/ContextUpgradeable.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/HelloWorld.d.ts +359 -0
- package/dist/src/types/contracts/flattened.sol/HelloWorld.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/HelloWorld.js +4 -0
- package/dist/src/types/contracts/flattened.sol/HelloWorld.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/HyperlaneConnectionClient.d.ts +202 -0
- package/dist/src/types/contracts/flattened.sol/HyperlaneConnectionClient.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/HyperlaneConnectionClient.js +4 -0
- package/dist/src/types/contracts/flattened.sol/HyperlaneConnectionClient.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainGasPaymaster.d.ts +51 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainGasPaymaster.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainGasPaymaster.js +4 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainGasPaymaster.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainSecurityModule.d.ts +59 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainSecurityModule.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainSecurityModule.js +4 -0
- package/dist/src/types/contracts/flattened.sol/IInterchainSecurityModule.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IMailbox.d.ts +107 -0
- package/dist/src/types/contracts/flattened.sol/IMailbox.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IMailbox.js +4 -0
- package/dist/src/types/contracts/flattened.sol/IMailbox.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IMessageRecipient.d.ts +51 -0
- package/dist/src/types/contracts/flattened.sol/IMessageRecipient.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/IMessageRecipient.js +4 -0
- package/dist/src/types/contracts/flattened.sol/IMessageRecipient.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/ISpecifiesInterchainSecurityModule.d.ts +43 -0
- package/dist/src/types/contracts/flattened.sol/ISpecifiesInterchainSecurityModule.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/ISpecifiesInterchainSecurityModule.js +4 -0
- package/dist/src/types/contracts/flattened.sol/ISpecifiesInterchainSecurityModule.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/Initializable.d.ts +40 -0
- package/dist/src/types/contracts/flattened.sol/Initializable.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/Initializable.js +4 -0
- package/dist/src/types/contracts/flattened.sol/Initializable.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/OwnableUpgradeable.d.ts +99 -0
- package/dist/src/types/contracts/flattened.sol/OwnableUpgradeable.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/OwnableUpgradeable.js +4 -0
- package/dist/src/types/contracts/flattened.sol/OwnableUpgradeable.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/Router.d.ts +279 -0
- package/dist/src/types/contracts/flattened.sol/Router.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/Router.js +4 -0
- package/dist/src/types/contracts/flattened.sol/Router.js.map +1 -0
- package/dist/src/types/contracts/flattened.sol/index.d.ts +12 -0
- package/dist/src/types/contracts/flattened.sol/index.d.ts.map +1 -0
- package/dist/src/types/contracts/flattened.sol/index.js +3 -0
- package/dist/src/types/contracts/flattened.sol/index.js.map +1 -0
- package/dist/src/types/contracts/index.d.ts +4 -0
- package/dist/src/types/contracts/index.d.ts.map +1 -0
- package/dist/src/types/contracts/index.js +4 -0
- package/dist/src/types/contracts/index.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient__factory.d.ts +43 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient__factory.js +200 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/HyperlaneConnectionClient__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/Router__factory.d.ts +36 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/Router__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/Router__factory.js +310 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/Router__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/index.d.ts +3 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/index.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/index.js +11 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/contracts/index.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/index.d.ts +3 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/index.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/index.js +32 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/index.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster__factory.d.ts +19 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster__factory.js +46 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainGasPaymaster__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule__factory.d.ts +23 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule__factory.js +55 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/IInterchainSecurityModule__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule__factory.d.ts +19 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule__factory.js +31 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/ISpecifiesInterchainSecurityModule__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.d.ts +3 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.js +11 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol/index.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMailbox__factory.d.ts +23 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMailbox__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMailbox__factory.js +141 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMailbox__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMessageRecipient__factory.d.ts +19 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMessageRecipient__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMessageRecipient__factory.js +41 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/IMessageRecipient__factory.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/index.d.ts +5 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/index.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/index.js +37 -0
- package/dist/src/types/factories/@hyperlane-xyz/core/interfaces/index.js.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/index.d.ts +2 -0
- package/dist/src/types/factories/@hyperlane-xyz/index.d.ts.map +1 -0
- package/dist/src/types/factories/@hyperlane-xyz/index.js +31 -0
- package/dist/src/types/factories/@hyperlane-xyz/index.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.d.ts +43 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.js +83 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/index.d.ts +2 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/index.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/index.js +9 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/access/index.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/index.d.ts +4 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/index.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/index.js +33 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/index.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/index.d.ts +2 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/index.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/index.js +31 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/index.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.d.ts +19 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.js +31 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts +2 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.js +9 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.d.ts +19 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.js +31 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/index.d.ts +2 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/index.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/index.js +9 -0
- package/dist/src/types/factories/@openzeppelin/contracts-upgradeable/utils/index.js.map +1 -0
- package/dist/src/types/factories/@openzeppelin/index.d.ts +2 -0
- package/dist/src/types/factories/@openzeppelin/index.d.ts.map +1 -0
- package/dist/src/types/factories/@openzeppelin/index.js +31 -0
- package/dist/src/types/factories/@openzeppelin/index.js.map +1 -0
- package/dist/src/types/factories/contracts/HelloWorld__factory.d.ts +59 -0
- package/dist/src/types/factories/contracts/HelloWorld__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/HelloWorld__factory.js +487 -0
- package/dist/src/types/factories/contracts/HelloWorld__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/ContextUpgradeable__factory.d.ts +19 -0
- package/dist/src/types/factories/contracts/flattened.sol/ContextUpgradeable__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/ContextUpgradeable__factory.js +31 -0
- package/dist/src/types/factories/contracts/flattened.sol/ContextUpgradeable__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/HelloWorld__factory.d.ts +59 -0
- package/dist/src/types/factories/contracts/flattened.sol/HelloWorld__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/HelloWorld__factory.js +487 -0
- package/dist/src/types/factories/contracts/flattened.sol/HelloWorld__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/HyperlaneConnectionClient__factory.d.ts +43 -0
- package/dist/src/types/factories/contracts/flattened.sol/HyperlaneConnectionClient__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/HyperlaneConnectionClient__factory.js +200 -0
- package/dist/src/types/factories/contracts/flattened.sol/HyperlaneConnectionClient__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainGasPaymaster__factory.d.ts +19 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainGasPaymaster__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainGasPaymaster__factory.js +46 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainGasPaymaster__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainSecurityModule__factory.d.ts +23 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainSecurityModule__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainSecurityModule__factory.js +55 -0
- package/dist/src/types/factories/contracts/flattened.sol/IInterchainSecurityModule__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMailbox__factory.d.ts +23 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMailbox__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMailbox__factory.js +141 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMailbox__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMessageRecipient__factory.d.ts +19 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMessageRecipient__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMessageRecipient__factory.js +41 -0
- package/dist/src/types/factories/contracts/flattened.sol/IMessageRecipient__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/ISpecifiesInterchainSecurityModule__factory.d.ts +19 -0
- package/dist/src/types/factories/contracts/flattened.sol/ISpecifiesInterchainSecurityModule__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/ISpecifiesInterchainSecurityModule__factory.js +31 -0
- package/dist/src/types/factories/contracts/flattened.sol/ISpecifiesInterchainSecurityModule__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/Initializable__factory.d.ts +19 -0
- package/dist/src/types/factories/contracts/flattened.sol/Initializable__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/Initializable__factory.js +31 -0
- package/dist/src/types/factories/contracts/flattened.sol/Initializable__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/OwnableUpgradeable__factory.d.ts +43 -0
- package/dist/src/types/factories/contracts/flattened.sol/OwnableUpgradeable__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/OwnableUpgradeable__factory.js +83 -0
- package/dist/src/types/factories/contracts/flattened.sol/OwnableUpgradeable__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/Router__factory.d.ts +36 -0
- package/dist/src/types/factories/contracts/flattened.sol/Router__factory.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/Router__factory.js +310 -0
- package/dist/src/types/factories/contracts/flattened.sol/Router__factory.js.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/index.d.ts +12 -0
- package/dist/src/types/factories/contracts/flattened.sol/index.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/flattened.sol/index.js +29 -0
- package/dist/src/types/factories/contracts/flattened.sol/index.js.map +1 -0
- package/dist/src/types/factories/contracts/index.d.ts +3 -0
- package/dist/src/types/factories/contracts/index.d.ts.map +1 -0
- package/dist/src/types/factories/contracts/index.js +33 -0
- package/dist/src/types/factories/contracts/index.js.map +1 -0
- package/dist/src/types/factories/index.d.ts +4 -0
- package/dist/src/types/factories/index.d.ts.map +1 -0
- package/dist/src/types/factories/index.js +33 -0
- package/dist/src/types/factories/index.js.map +1 -0
- package/dist/src/types/index.d.ts +30 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +51 -0
- package/dist/src/types/index.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,2593 @@
|
|
|
1
|
+
// Sources flattened with hardhat v2.9.9 https://hardhat.org
|
|
2
|
+
|
|
3
|
+
// File @hyperlane-xyz/core/interfaces/IInterchainGasPaymaster.sol@v1.0.0-beta6
|
|
4
|
+
|
|
5
|
+
// SPDX-License-Identifier: MIT
|
|
6
|
+
pragma solidity >=0.6.11;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title IInterchainGasPaymaster
|
|
10
|
+
* @notice Manages payments on a source chain to cover gas costs of relaying
|
|
11
|
+
* messages to destination chains.
|
|
12
|
+
*/
|
|
13
|
+
interface IInterchainGasPaymaster {
|
|
14
|
+
function payForGas(
|
|
15
|
+
bytes32 _messageId,
|
|
16
|
+
uint32 _destinationDomain,
|
|
17
|
+
uint256 _gas,
|
|
18
|
+
address _refundAddress
|
|
19
|
+
) external payable;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// File @hyperlane-xyz/core/interfaces/IInterchainSecurityModule.sol@v1.0.0-beta6
|
|
23
|
+
|
|
24
|
+
pragma solidity >=0.6.11;
|
|
25
|
+
|
|
26
|
+
interface IInterchainSecurityModule {
|
|
27
|
+
/**
|
|
28
|
+
* @notice Returns an enum that represents the type of security model
|
|
29
|
+
* encoded by this ISM.
|
|
30
|
+
* @dev Relayers infer how to fetch and format metadata.
|
|
31
|
+
*/
|
|
32
|
+
function moduleType() external view returns (uint8);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @notice Defines a security model responsible for verifying interchain
|
|
36
|
+
* messages based on the provided metadata.
|
|
37
|
+
* @param _metadata Off-chain metadata provided by a relayer, specific to
|
|
38
|
+
* the security model encoded by the module (e.g. validator signatures)
|
|
39
|
+
* @param _message Hyperlane encoded interchain message
|
|
40
|
+
* @return True if the message was verified
|
|
41
|
+
*/
|
|
42
|
+
function verify(bytes calldata _metadata, bytes calldata _message)
|
|
43
|
+
external
|
|
44
|
+
returns (bool);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ISpecifiesInterchainSecurityModule {
|
|
48
|
+
function interchainSecurityModule()
|
|
49
|
+
external
|
|
50
|
+
view
|
|
51
|
+
returns (IInterchainSecurityModule);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// File @hyperlane-xyz/core/interfaces/IMailbox.sol@v1.0.0-beta6
|
|
55
|
+
|
|
56
|
+
pragma solidity >=0.8.0;
|
|
57
|
+
|
|
58
|
+
interface IMailbox {
|
|
59
|
+
function localDomain() external view returns (uint32);
|
|
60
|
+
|
|
61
|
+
function dispatch(
|
|
62
|
+
uint32 _destinationDomain,
|
|
63
|
+
bytes32 _recipientAddress,
|
|
64
|
+
bytes calldata _messageBody
|
|
65
|
+
) external returns (bytes32);
|
|
66
|
+
|
|
67
|
+
function process(bytes calldata _metadata, bytes calldata _message)
|
|
68
|
+
external;
|
|
69
|
+
|
|
70
|
+
function count() external view returns (uint32);
|
|
71
|
+
|
|
72
|
+
function root() external view returns (bytes32);
|
|
73
|
+
|
|
74
|
+
function latestCheckpoint() external view returns (bytes32, uint32);
|
|
75
|
+
|
|
76
|
+
function recipientIsm(address _recipient)
|
|
77
|
+
external
|
|
78
|
+
view
|
|
79
|
+
returns (IInterchainSecurityModule);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// File @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol@v4.8.0
|
|
83
|
+
|
|
84
|
+
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
|
|
85
|
+
|
|
86
|
+
pragma solidity ^0.8.1;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @dev Collection of functions related to the address type
|
|
90
|
+
*/
|
|
91
|
+
library AddressUpgradeable {
|
|
92
|
+
/**
|
|
93
|
+
* @dev Returns true if `account` is a contract.
|
|
94
|
+
*
|
|
95
|
+
* [IMPORTANT]
|
|
96
|
+
* ====
|
|
97
|
+
* It is unsafe to assume that an address for which this function returns
|
|
98
|
+
* false is an externally-owned account (EOA) and not a contract.
|
|
99
|
+
*
|
|
100
|
+
* Among others, `isContract` will return false for the following
|
|
101
|
+
* types of addresses:
|
|
102
|
+
*
|
|
103
|
+
* - an externally-owned account
|
|
104
|
+
* - a contract in construction
|
|
105
|
+
* - an address where a contract will be created
|
|
106
|
+
* - an address where a contract lived, but was destroyed
|
|
107
|
+
* ====
|
|
108
|
+
*
|
|
109
|
+
* [IMPORTANT]
|
|
110
|
+
* ====
|
|
111
|
+
* You shouldn't rely on `isContract` to protect against flash loan attacks!
|
|
112
|
+
*
|
|
113
|
+
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
|
|
114
|
+
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
|
|
115
|
+
* constructor.
|
|
116
|
+
* ====
|
|
117
|
+
*/
|
|
118
|
+
function isContract(address account) internal view returns (bool) {
|
|
119
|
+
// This method relies on extcodesize/address.code.length, which returns 0
|
|
120
|
+
// for contracts in construction, since the code is only stored at the end
|
|
121
|
+
// of the constructor execution.
|
|
122
|
+
|
|
123
|
+
return account.code.length > 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
|
|
128
|
+
* `recipient`, forwarding all available gas and reverting on errors.
|
|
129
|
+
*
|
|
130
|
+
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
|
|
131
|
+
* of certain opcodes, possibly making contracts go over the 2300 gas limit
|
|
132
|
+
* imposed by `transfer`, making them unable to receive funds via
|
|
133
|
+
* `transfer`. {sendValue} removes this limitation.
|
|
134
|
+
*
|
|
135
|
+
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
|
|
136
|
+
*
|
|
137
|
+
* IMPORTANT: because control is transferred to `recipient`, care must be
|
|
138
|
+
* taken to not create reentrancy vulnerabilities. Consider using
|
|
139
|
+
* {ReentrancyGuard} or the
|
|
140
|
+
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
|
|
141
|
+
*/
|
|
142
|
+
function sendValue(address payable recipient, uint256 amount) internal {
|
|
143
|
+
require(
|
|
144
|
+
address(this).balance >= amount,
|
|
145
|
+
"Address: insufficient balance"
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
(bool success, ) = recipient.call{value: amount}("");
|
|
149
|
+
require(
|
|
150
|
+
success,
|
|
151
|
+
"Address: unable to send value, recipient may have reverted"
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* @dev Performs a Solidity function call using a low level `call`. A
|
|
157
|
+
* plain `call` is an unsafe replacement for a function call: use this
|
|
158
|
+
* function instead.
|
|
159
|
+
*
|
|
160
|
+
* If `target` reverts with a revert reason, it is bubbled up by this
|
|
161
|
+
* function (like regular Solidity function calls).
|
|
162
|
+
*
|
|
163
|
+
* Returns the raw returned data. To convert to the expected return value,
|
|
164
|
+
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
|
|
165
|
+
*
|
|
166
|
+
* Requirements:
|
|
167
|
+
*
|
|
168
|
+
* - `target` must be a contract.
|
|
169
|
+
* - calling `target` with `data` must not revert.
|
|
170
|
+
*
|
|
171
|
+
* _Available since v3.1._
|
|
172
|
+
*/
|
|
173
|
+
function functionCall(address target, bytes memory data)
|
|
174
|
+
internal
|
|
175
|
+
returns (bytes memory)
|
|
176
|
+
{
|
|
177
|
+
return
|
|
178
|
+
functionCallWithValue(
|
|
179
|
+
target,
|
|
180
|
+
data,
|
|
181
|
+
0,
|
|
182
|
+
"Address: low-level call failed"
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
|
|
188
|
+
* `errorMessage` as a fallback revert reason when `target` reverts.
|
|
189
|
+
*
|
|
190
|
+
* _Available since v3.1._
|
|
191
|
+
*/
|
|
192
|
+
function functionCall(
|
|
193
|
+
address target,
|
|
194
|
+
bytes memory data,
|
|
195
|
+
string memory errorMessage
|
|
196
|
+
) internal returns (bytes memory) {
|
|
197
|
+
return functionCallWithValue(target, data, 0, errorMessage);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
|
202
|
+
* but also transferring `value` wei to `target`.
|
|
203
|
+
*
|
|
204
|
+
* Requirements:
|
|
205
|
+
*
|
|
206
|
+
* - the calling contract must have an ETH balance of at least `value`.
|
|
207
|
+
* - the called Solidity function must be `payable`.
|
|
208
|
+
*
|
|
209
|
+
* _Available since v3.1._
|
|
210
|
+
*/
|
|
211
|
+
function functionCallWithValue(
|
|
212
|
+
address target,
|
|
213
|
+
bytes memory data,
|
|
214
|
+
uint256 value
|
|
215
|
+
) internal returns (bytes memory) {
|
|
216
|
+
return
|
|
217
|
+
functionCallWithValue(
|
|
218
|
+
target,
|
|
219
|
+
data,
|
|
220
|
+
value,
|
|
221
|
+
"Address: low-level call with value failed"
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
|
|
227
|
+
* with `errorMessage` as a fallback revert reason when `target` reverts.
|
|
228
|
+
*
|
|
229
|
+
* _Available since v3.1._
|
|
230
|
+
*/
|
|
231
|
+
function functionCallWithValue(
|
|
232
|
+
address target,
|
|
233
|
+
bytes memory data,
|
|
234
|
+
uint256 value,
|
|
235
|
+
string memory errorMessage
|
|
236
|
+
) internal returns (bytes memory) {
|
|
237
|
+
require(
|
|
238
|
+
address(this).balance >= value,
|
|
239
|
+
"Address: insufficient balance for call"
|
|
240
|
+
);
|
|
241
|
+
(bool success, bytes memory returndata) = target.call{value: value}(
|
|
242
|
+
data
|
|
243
|
+
);
|
|
244
|
+
return
|
|
245
|
+
verifyCallResultFromTarget(
|
|
246
|
+
target,
|
|
247
|
+
success,
|
|
248
|
+
returndata,
|
|
249
|
+
errorMessage
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
|
255
|
+
* but performing a static call.
|
|
256
|
+
*
|
|
257
|
+
* _Available since v3.3._
|
|
258
|
+
*/
|
|
259
|
+
function functionStaticCall(address target, bytes memory data)
|
|
260
|
+
internal
|
|
261
|
+
view
|
|
262
|
+
returns (bytes memory)
|
|
263
|
+
{
|
|
264
|
+
return
|
|
265
|
+
functionStaticCall(
|
|
266
|
+
target,
|
|
267
|
+
data,
|
|
268
|
+
"Address: low-level static call failed"
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
|
|
274
|
+
* but performing a static call.
|
|
275
|
+
*
|
|
276
|
+
* _Available since v3.3._
|
|
277
|
+
*/
|
|
278
|
+
function functionStaticCall(
|
|
279
|
+
address target,
|
|
280
|
+
bytes memory data,
|
|
281
|
+
string memory errorMessage
|
|
282
|
+
) internal view returns (bytes memory) {
|
|
283
|
+
(bool success, bytes memory returndata) = target.staticcall(data);
|
|
284
|
+
return
|
|
285
|
+
verifyCallResultFromTarget(
|
|
286
|
+
target,
|
|
287
|
+
success,
|
|
288
|
+
returndata,
|
|
289
|
+
errorMessage
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
|
|
295
|
+
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
|
|
296
|
+
*
|
|
297
|
+
* _Available since v4.8._
|
|
298
|
+
*/
|
|
299
|
+
function verifyCallResultFromTarget(
|
|
300
|
+
address target,
|
|
301
|
+
bool success,
|
|
302
|
+
bytes memory returndata,
|
|
303
|
+
string memory errorMessage
|
|
304
|
+
) internal view returns (bytes memory) {
|
|
305
|
+
if (success) {
|
|
306
|
+
if (returndata.length == 0) {
|
|
307
|
+
// only check isContract if the call was successful and the return data is empty
|
|
308
|
+
// otherwise we already know that it was a contract
|
|
309
|
+
require(isContract(target), "Address: call to non-contract");
|
|
310
|
+
}
|
|
311
|
+
return returndata;
|
|
312
|
+
} else {
|
|
313
|
+
_revert(returndata, errorMessage);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
|
|
319
|
+
* revert reason or using the provided one.
|
|
320
|
+
*
|
|
321
|
+
* _Available since v4.3._
|
|
322
|
+
*/
|
|
323
|
+
function verifyCallResult(
|
|
324
|
+
bool success,
|
|
325
|
+
bytes memory returndata,
|
|
326
|
+
string memory errorMessage
|
|
327
|
+
) internal pure returns (bytes memory) {
|
|
328
|
+
if (success) {
|
|
329
|
+
return returndata;
|
|
330
|
+
} else {
|
|
331
|
+
_revert(returndata, errorMessage);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function _revert(bytes memory returndata, string memory errorMessage)
|
|
336
|
+
private
|
|
337
|
+
pure
|
|
338
|
+
{
|
|
339
|
+
// Look for revert reason and bubble it up if present
|
|
340
|
+
if (returndata.length > 0) {
|
|
341
|
+
// The easiest way to bubble the revert reason is using memory via assembly
|
|
342
|
+
/// @solidity memory-safe-assembly
|
|
343
|
+
assembly {
|
|
344
|
+
let returndata_size := mload(returndata)
|
|
345
|
+
revert(add(32, returndata), returndata_size)
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
revert(errorMessage);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// File @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol@v4.8.0
|
|
354
|
+
|
|
355
|
+
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)
|
|
356
|
+
|
|
357
|
+
pragma solidity ^0.8.2;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
|
|
361
|
+
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
|
|
362
|
+
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
|
|
363
|
+
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
|
|
364
|
+
*
|
|
365
|
+
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
|
|
366
|
+
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
|
|
367
|
+
* case an upgrade adds a module that needs to be initialized.
|
|
368
|
+
*
|
|
369
|
+
* For example:
|
|
370
|
+
*
|
|
371
|
+
* [.hljs-theme-light.nopadding]
|
|
372
|
+
* ```
|
|
373
|
+
* contract MyToken is ERC20Upgradeable {
|
|
374
|
+
* function initialize() initializer public {
|
|
375
|
+
* __ERC20_init("MyToken", "MTK");
|
|
376
|
+
* }
|
|
377
|
+
* }
|
|
378
|
+
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
|
|
379
|
+
* function initializeV2() reinitializer(2) public {
|
|
380
|
+
* __ERC20Permit_init("MyToken");
|
|
381
|
+
* }
|
|
382
|
+
* }
|
|
383
|
+
* ```
|
|
384
|
+
*
|
|
385
|
+
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
|
|
386
|
+
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
|
|
387
|
+
*
|
|
388
|
+
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
|
|
389
|
+
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
|
|
390
|
+
*
|
|
391
|
+
* [CAUTION]
|
|
392
|
+
* ====
|
|
393
|
+
* Avoid leaving a contract uninitialized.
|
|
394
|
+
*
|
|
395
|
+
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
|
|
396
|
+
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
|
|
397
|
+
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
|
|
398
|
+
*
|
|
399
|
+
* [.hljs-theme-light.nopadding]
|
|
400
|
+
* ```
|
|
401
|
+
* /// @custom:oz-upgrades-unsafe-allow constructor
|
|
402
|
+
* constructor() {
|
|
403
|
+
* _disableInitializers();
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
* ====
|
|
407
|
+
*/
|
|
408
|
+
abstract contract Initializable {
|
|
409
|
+
/**
|
|
410
|
+
* @dev Indicates that the contract has been initialized.
|
|
411
|
+
* @custom:oz-retyped-from bool
|
|
412
|
+
*/
|
|
413
|
+
uint8 private _initialized;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* @dev Indicates that the contract is in the process of being initialized.
|
|
417
|
+
*/
|
|
418
|
+
bool private _initializing;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @dev Triggered when the contract has been initialized or reinitialized.
|
|
422
|
+
*/
|
|
423
|
+
event Initialized(uint8 version);
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
|
|
427
|
+
* `onlyInitializing` functions can be used to initialize parent contracts.
|
|
428
|
+
*
|
|
429
|
+
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
|
|
430
|
+
* constructor.
|
|
431
|
+
*
|
|
432
|
+
* Emits an {Initialized} event.
|
|
433
|
+
*/
|
|
434
|
+
modifier initializer() {
|
|
435
|
+
bool isTopLevelCall = !_initializing;
|
|
436
|
+
require(
|
|
437
|
+
(isTopLevelCall && _initialized < 1) ||
|
|
438
|
+
(!AddressUpgradeable.isContract(address(this)) &&
|
|
439
|
+
_initialized == 1),
|
|
440
|
+
"Initializable: contract is already initialized"
|
|
441
|
+
);
|
|
442
|
+
_initialized = 1;
|
|
443
|
+
if (isTopLevelCall) {
|
|
444
|
+
_initializing = true;
|
|
445
|
+
}
|
|
446
|
+
_;
|
|
447
|
+
if (isTopLevelCall) {
|
|
448
|
+
_initializing = false;
|
|
449
|
+
emit Initialized(1);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
|
|
455
|
+
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
|
|
456
|
+
* used to initialize parent contracts.
|
|
457
|
+
*
|
|
458
|
+
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
|
|
459
|
+
* are added through upgrades and that require initialization.
|
|
460
|
+
*
|
|
461
|
+
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
|
|
462
|
+
* cannot be nested. If one is invoked in the context of another, execution will revert.
|
|
463
|
+
*
|
|
464
|
+
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
|
|
465
|
+
* a contract, executing them in the right order is up to the developer or operator.
|
|
466
|
+
*
|
|
467
|
+
* WARNING: setting the version to 255 will prevent any future reinitialization.
|
|
468
|
+
*
|
|
469
|
+
* Emits an {Initialized} event.
|
|
470
|
+
*/
|
|
471
|
+
modifier reinitializer(uint8 version) {
|
|
472
|
+
require(
|
|
473
|
+
!_initializing && _initialized < version,
|
|
474
|
+
"Initializable: contract is already initialized"
|
|
475
|
+
);
|
|
476
|
+
_initialized = version;
|
|
477
|
+
_initializing = true;
|
|
478
|
+
_;
|
|
479
|
+
_initializing = false;
|
|
480
|
+
emit Initialized(version);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
|
|
485
|
+
* {initializer} and {reinitializer} modifiers, directly or indirectly.
|
|
486
|
+
*/
|
|
487
|
+
modifier onlyInitializing() {
|
|
488
|
+
require(_initializing, "Initializable: contract is not initializing");
|
|
489
|
+
_;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
|
|
494
|
+
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
|
|
495
|
+
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
|
|
496
|
+
* through proxies.
|
|
497
|
+
*
|
|
498
|
+
* Emits an {Initialized} event the first time it is successfully executed.
|
|
499
|
+
*/
|
|
500
|
+
function _disableInitializers() internal virtual {
|
|
501
|
+
require(!_initializing, "Initializable: contract is initializing");
|
|
502
|
+
if (_initialized < type(uint8).max) {
|
|
503
|
+
_initialized = type(uint8).max;
|
|
504
|
+
emit Initialized(type(uint8).max);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* @dev Internal function that returns the initialized version. Returns `_initialized`
|
|
510
|
+
*/
|
|
511
|
+
function _getInitializedVersion() internal view returns (uint8) {
|
|
512
|
+
return _initialized;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @dev Internal function that returns the initialized version. Returns `_initializing`
|
|
517
|
+
*/
|
|
518
|
+
function _isInitializing() internal view returns (bool) {
|
|
519
|
+
return _initializing;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// File @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol@v4.8.0
|
|
524
|
+
|
|
525
|
+
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
|
|
526
|
+
|
|
527
|
+
pragma solidity ^0.8.0;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* @dev Provides information about the current execution context, including the
|
|
531
|
+
* sender of the transaction and its data. While these are generally available
|
|
532
|
+
* via msg.sender and msg.data, they should not be accessed in such a direct
|
|
533
|
+
* manner, since when dealing with meta-transactions the account sending and
|
|
534
|
+
* paying for execution may not be the actual sender (as far as an application
|
|
535
|
+
* is concerned).
|
|
536
|
+
*
|
|
537
|
+
* This contract is only required for intermediate, library-like contracts.
|
|
538
|
+
*/
|
|
539
|
+
abstract contract ContextUpgradeable is Initializable {
|
|
540
|
+
function __Context_init() internal onlyInitializing {}
|
|
541
|
+
|
|
542
|
+
function __Context_init_unchained() internal onlyInitializing {}
|
|
543
|
+
|
|
544
|
+
function _msgSender() internal view virtual returns (address) {
|
|
545
|
+
return msg.sender;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function _msgData() internal view virtual returns (bytes calldata) {
|
|
549
|
+
return msg.data;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* @dev This empty reserved space is put in place to allow future versions to add new
|
|
554
|
+
* variables without shifting down storage in the inheritance chain.
|
|
555
|
+
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
556
|
+
*/
|
|
557
|
+
uint256[50] private __gap;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// File @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol@v4.8.0
|
|
561
|
+
|
|
562
|
+
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
|
|
563
|
+
|
|
564
|
+
pragma solidity ^0.8.0;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* @dev Contract module which provides a basic access control mechanism, where
|
|
568
|
+
* there is an account (an owner) that can be granted exclusive access to
|
|
569
|
+
* specific functions.
|
|
570
|
+
*
|
|
571
|
+
* By default, the owner account will be the one that deploys the contract. This
|
|
572
|
+
* can later be changed with {transferOwnership}.
|
|
573
|
+
*
|
|
574
|
+
* This module is used through inheritance. It will make available the modifier
|
|
575
|
+
* `onlyOwner`, which can be applied to your functions to restrict their use to
|
|
576
|
+
* the owner.
|
|
577
|
+
*/
|
|
578
|
+
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
|
|
579
|
+
address private _owner;
|
|
580
|
+
|
|
581
|
+
event OwnershipTransferred(
|
|
582
|
+
address indexed previousOwner,
|
|
583
|
+
address indexed newOwner
|
|
584
|
+
);
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @dev Initializes the contract setting the deployer as the initial owner.
|
|
588
|
+
*/
|
|
589
|
+
function __Ownable_init() internal onlyInitializing {
|
|
590
|
+
__Ownable_init_unchained();
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function __Ownable_init_unchained() internal onlyInitializing {
|
|
594
|
+
_transferOwnership(_msgSender());
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* @dev Throws if called by any account other than the owner.
|
|
599
|
+
*/
|
|
600
|
+
modifier onlyOwner() {
|
|
601
|
+
_checkOwner();
|
|
602
|
+
_;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* @dev Returns the address of the current owner.
|
|
607
|
+
*/
|
|
608
|
+
function owner() public view virtual returns (address) {
|
|
609
|
+
return _owner;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* @dev Throws if the sender is not the owner.
|
|
614
|
+
*/
|
|
615
|
+
function _checkOwner() internal view virtual {
|
|
616
|
+
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* @dev Leaves the contract without owner. It will not be possible to call
|
|
621
|
+
* `onlyOwner` functions anymore. Can only be called by the current owner.
|
|
622
|
+
*
|
|
623
|
+
* NOTE: Renouncing ownership will leave the contract without an owner,
|
|
624
|
+
* thereby removing any functionality that is only available to the owner.
|
|
625
|
+
*/
|
|
626
|
+
function renounceOwnership() public virtual onlyOwner {
|
|
627
|
+
_transferOwnership(address(0));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
632
|
+
* Can only be called by the current owner.
|
|
633
|
+
*/
|
|
634
|
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
|
635
|
+
require(
|
|
636
|
+
newOwner != address(0),
|
|
637
|
+
"Ownable: new owner is the zero address"
|
|
638
|
+
);
|
|
639
|
+
_transferOwnership(newOwner);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
644
|
+
* Internal function without access restriction.
|
|
645
|
+
*/
|
|
646
|
+
function _transferOwnership(address newOwner) internal virtual {
|
|
647
|
+
address oldOwner = _owner;
|
|
648
|
+
_owner = newOwner;
|
|
649
|
+
emit OwnershipTransferred(oldOwner, newOwner);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* @dev This empty reserved space is put in place to allow future versions to add new
|
|
654
|
+
* variables without shifting down storage in the inheritance chain.
|
|
655
|
+
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
|
|
656
|
+
*/
|
|
657
|
+
uint256[49] private __gap;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// File @openzeppelin/contracts/utils/Address.sol@v4.8.0
|
|
661
|
+
|
|
662
|
+
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
|
|
663
|
+
|
|
664
|
+
pragma solidity ^0.8.1;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @dev Collection of functions related to the address type
|
|
668
|
+
*/
|
|
669
|
+
library Address {
|
|
670
|
+
/**
|
|
671
|
+
* @dev Returns true if `account` is a contract.
|
|
672
|
+
*
|
|
673
|
+
* [IMPORTANT]
|
|
674
|
+
* ====
|
|
675
|
+
* It is unsafe to assume that an address for which this function returns
|
|
676
|
+
* false is an externally-owned account (EOA) and not a contract.
|
|
677
|
+
*
|
|
678
|
+
* Among others, `isContract` will return false for the following
|
|
679
|
+
* types of addresses:
|
|
680
|
+
*
|
|
681
|
+
* - an externally-owned account
|
|
682
|
+
* - a contract in construction
|
|
683
|
+
* - an address where a contract will be created
|
|
684
|
+
* - an address where a contract lived, but was destroyed
|
|
685
|
+
* ====
|
|
686
|
+
*
|
|
687
|
+
* [IMPORTANT]
|
|
688
|
+
* ====
|
|
689
|
+
* You shouldn't rely on `isContract` to protect against flash loan attacks!
|
|
690
|
+
*
|
|
691
|
+
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
|
|
692
|
+
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
|
|
693
|
+
* constructor.
|
|
694
|
+
* ====
|
|
695
|
+
*/
|
|
696
|
+
function isContract(address account) internal view returns (bool) {
|
|
697
|
+
// This method relies on extcodesize/address.code.length, which returns 0
|
|
698
|
+
// for contracts in construction, since the code is only stored at the end
|
|
699
|
+
// of the constructor execution.
|
|
700
|
+
|
|
701
|
+
return account.code.length > 0;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
|
|
706
|
+
* `recipient`, forwarding all available gas and reverting on errors.
|
|
707
|
+
*
|
|
708
|
+
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
|
|
709
|
+
* of certain opcodes, possibly making contracts go over the 2300 gas limit
|
|
710
|
+
* imposed by `transfer`, making them unable to receive funds via
|
|
711
|
+
* `transfer`. {sendValue} removes this limitation.
|
|
712
|
+
*
|
|
713
|
+
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
|
|
714
|
+
*
|
|
715
|
+
* IMPORTANT: because control is transferred to `recipient`, care must be
|
|
716
|
+
* taken to not create reentrancy vulnerabilities. Consider using
|
|
717
|
+
* {ReentrancyGuard} or the
|
|
718
|
+
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
|
|
719
|
+
*/
|
|
720
|
+
function sendValue(address payable recipient, uint256 amount) internal {
|
|
721
|
+
require(
|
|
722
|
+
address(this).balance >= amount,
|
|
723
|
+
"Address: insufficient balance"
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
(bool success, ) = recipient.call{value: amount}("");
|
|
727
|
+
require(
|
|
728
|
+
success,
|
|
729
|
+
"Address: unable to send value, recipient may have reverted"
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* @dev Performs a Solidity function call using a low level `call`. A
|
|
735
|
+
* plain `call` is an unsafe replacement for a function call: use this
|
|
736
|
+
* function instead.
|
|
737
|
+
*
|
|
738
|
+
* If `target` reverts with a revert reason, it is bubbled up by this
|
|
739
|
+
* function (like regular Solidity function calls).
|
|
740
|
+
*
|
|
741
|
+
* Returns the raw returned data. To convert to the expected return value,
|
|
742
|
+
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
|
|
743
|
+
*
|
|
744
|
+
* Requirements:
|
|
745
|
+
*
|
|
746
|
+
* - `target` must be a contract.
|
|
747
|
+
* - calling `target` with `data` must not revert.
|
|
748
|
+
*
|
|
749
|
+
* _Available since v3.1._
|
|
750
|
+
*/
|
|
751
|
+
function functionCall(address target, bytes memory data)
|
|
752
|
+
internal
|
|
753
|
+
returns (bytes memory)
|
|
754
|
+
{
|
|
755
|
+
return
|
|
756
|
+
functionCallWithValue(
|
|
757
|
+
target,
|
|
758
|
+
data,
|
|
759
|
+
0,
|
|
760
|
+
"Address: low-level call failed"
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
|
|
766
|
+
* `errorMessage` as a fallback revert reason when `target` reverts.
|
|
767
|
+
*
|
|
768
|
+
* _Available since v3.1._
|
|
769
|
+
*/
|
|
770
|
+
function functionCall(
|
|
771
|
+
address target,
|
|
772
|
+
bytes memory data,
|
|
773
|
+
string memory errorMessage
|
|
774
|
+
) internal returns (bytes memory) {
|
|
775
|
+
return functionCallWithValue(target, data, 0, errorMessage);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
|
780
|
+
* but also transferring `value` wei to `target`.
|
|
781
|
+
*
|
|
782
|
+
* Requirements:
|
|
783
|
+
*
|
|
784
|
+
* - the calling contract must have an ETH balance of at least `value`.
|
|
785
|
+
* - the called Solidity function must be `payable`.
|
|
786
|
+
*
|
|
787
|
+
* _Available since v3.1._
|
|
788
|
+
*/
|
|
789
|
+
function functionCallWithValue(
|
|
790
|
+
address target,
|
|
791
|
+
bytes memory data,
|
|
792
|
+
uint256 value
|
|
793
|
+
) internal returns (bytes memory) {
|
|
794
|
+
return
|
|
795
|
+
functionCallWithValue(
|
|
796
|
+
target,
|
|
797
|
+
data,
|
|
798
|
+
value,
|
|
799
|
+
"Address: low-level call with value failed"
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
|
|
805
|
+
* with `errorMessage` as a fallback revert reason when `target` reverts.
|
|
806
|
+
*
|
|
807
|
+
* _Available since v3.1._
|
|
808
|
+
*/
|
|
809
|
+
function functionCallWithValue(
|
|
810
|
+
address target,
|
|
811
|
+
bytes memory data,
|
|
812
|
+
uint256 value,
|
|
813
|
+
string memory errorMessage
|
|
814
|
+
) internal returns (bytes memory) {
|
|
815
|
+
require(
|
|
816
|
+
address(this).balance >= value,
|
|
817
|
+
"Address: insufficient balance for call"
|
|
818
|
+
);
|
|
819
|
+
(bool success, bytes memory returndata) = target.call{value: value}(
|
|
820
|
+
data
|
|
821
|
+
);
|
|
822
|
+
return
|
|
823
|
+
verifyCallResultFromTarget(
|
|
824
|
+
target,
|
|
825
|
+
success,
|
|
826
|
+
returndata,
|
|
827
|
+
errorMessage
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
/**
|
|
832
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
|
833
|
+
* but performing a static call.
|
|
834
|
+
*
|
|
835
|
+
* _Available since v3.3._
|
|
836
|
+
*/
|
|
837
|
+
function functionStaticCall(address target, bytes memory data)
|
|
838
|
+
internal
|
|
839
|
+
view
|
|
840
|
+
returns (bytes memory)
|
|
841
|
+
{
|
|
842
|
+
return
|
|
843
|
+
functionStaticCall(
|
|
844
|
+
target,
|
|
845
|
+
data,
|
|
846
|
+
"Address: low-level static call failed"
|
|
847
|
+
);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
|
|
852
|
+
* but performing a static call.
|
|
853
|
+
*
|
|
854
|
+
* _Available since v3.3._
|
|
855
|
+
*/
|
|
856
|
+
function functionStaticCall(
|
|
857
|
+
address target,
|
|
858
|
+
bytes memory data,
|
|
859
|
+
string memory errorMessage
|
|
860
|
+
) internal view returns (bytes memory) {
|
|
861
|
+
(bool success, bytes memory returndata) = target.staticcall(data);
|
|
862
|
+
return
|
|
863
|
+
verifyCallResultFromTarget(
|
|
864
|
+
target,
|
|
865
|
+
success,
|
|
866
|
+
returndata,
|
|
867
|
+
errorMessage
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
|
873
|
+
* but performing a delegate call.
|
|
874
|
+
*
|
|
875
|
+
* _Available since v3.4._
|
|
876
|
+
*/
|
|
877
|
+
function functionDelegateCall(address target, bytes memory data)
|
|
878
|
+
internal
|
|
879
|
+
returns (bytes memory)
|
|
880
|
+
{
|
|
881
|
+
return
|
|
882
|
+
functionDelegateCall(
|
|
883
|
+
target,
|
|
884
|
+
data,
|
|
885
|
+
"Address: low-level delegate call failed"
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
|
|
891
|
+
* but performing a delegate call.
|
|
892
|
+
*
|
|
893
|
+
* _Available since v3.4._
|
|
894
|
+
*/
|
|
895
|
+
function functionDelegateCall(
|
|
896
|
+
address target,
|
|
897
|
+
bytes memory data,
|
|
898
|
+
string memory errorMessage
|
|
899
|
+
) internal returns (bytes memory) {
|
|
900
|
+
(bool success, bytes memory returndata) = target.delegatecall(data);
|
|
901
|
+
return
|
|
902
|
+
verifyCallResultFromTarget(
|
|
903
|
+
target,
|
|
904
|
+
success,
|
|
905
|
+
returndata,
|
|
906
|
+
errorMessage
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
|
|
912
|
+
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
|
|
913
|
+
*
|
|
914
|
+
* _Available since v4.8._
|
|
915
|
+
*/
|
|
916
|
+
function verifyCallResultFromTarget(
|
|
917
|
+
address target,
|
|
918
|
+
bool success,
|
|
919
|
+
bytes memory returndata,
|
|
920
|
+
string memory errorMessage
|
|
921
|
+
) internal view returns (bytes memory) {
|
|
922
|
+
if (success) {
|
|
923
|
+
if (returndata.length == 0) {
|
|
924
|
+
// only check isContract if the call was successful and the return data is empty
|
|
925
|
+
// otherwise we already know that it was a contract
|
|
926
|
+
require(isContract(target), "Address: call to non-contract");
|
|
927
|
+
}
|
|
928
|
+
return returndata;
|
|
929
|
+
} else {
|
|
930
|
+
_revert(returndata, errorMessage);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
|
|
936
|
+
* revert reason or using the provided one.
|
|
937
|
+
*
|
|
938
|
+
* _Available since v4.3._
|
|
939
|
+
*/
|
|
940
|
+
function verifyCallResult(
|
|
941
|
+
bool success,
|
|
942
|
+
bytes memory returndata,
|
|
943
|
+
string memory errorMessage
|
|
944
|
+
) internal pure returns (bytes memory) {
|
|
945
|
+
if (success) {
|
|
946
|
+
return returndata;
|
|
947
|
+
} else {
|
|
948
|
+
_revert(returndata, errorMessage);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function _revert(bytes memory returndata, string memory errorMessage)
|
|
953
|
+
private
|
|
954
|
+
pure
|
|
955
|
+
{
|
|
956
|
+
// Look for revert reason and bubble it up if present
|
|
957
|
+
if (returndata.length > 0) {
|
|
958
|
+
// The easiest way to bubble the revert reason is using memory via assembly
|
|
959
|
+
/// @solidity memory-safe-assembly
|
|
960
|
+
assembly {
|
|
961
|
+
let returndata_size := mload(returndata)
|
|
962
|
+
revert(add(32, returndata), returndata_size)
|
|
963
|
+
}
|
|
964
|
+
} else {
|
|
965
|
+
revert(errorMessage);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
// File @hyperlane-xyz/core/contracts/HyperlaneConnectionClient.sol@v1.0.0-beta6
|
|
971
|
+
|
|
972
|
+
pragma solidity >=0.6.11;
|
|
973
|
+
|
|
974
|
+
// ============ Internal Imports ============
|
|
975
|
+
|
|
976
|
+
// ============ External Imports ============
|
|
977
|
+
|
|
978
|
+
abstract contract HyperlaneConnectionClient is
|
|
979
|
+
OwnableUpgradeable,
|
|
980
|
+
ISpecifiesInterchainSecurityModule
|
|
981
|
+
{
|
|
982
|
+
// ============ Mutable Storage ============
|
|
983
|
+
|
|
984
|
+
IMailbox public mailbox;
|
|
985
|
+
// Interchain Gas Paymaster contract. The relayer associated with this contract
|
|
986
|
+
// must be willing to relay messages dispatched from the current Mailbox contract,
|
|
987
|
+
// otherwise payments made to the paymaster will not result in relayed messages.
|
|
988
|
+
IInterchainGasPaymaster public interchainGasPaymaster;
|
|
989
|
+
|
|
990
|
+
IInterchainSecurityModule public interchainSecurityModule;
|
|
991
|
+
|
|
992
|
+
uint256[48] private __GAP; // gap for upgrade safety
|
|
993
|
+
|
|
994
|
+
// ============ Events ============
|
|
995
|
+
/**
|
|
996
|
+
* @notice Emitted when a new mailbox is set.
|
|
997
|
+
* @param mailbox The address of the mailbox contract
|
|
998
|
+
*/
|
|
999
|
+
event MailboxSet(address indexed mailbox);
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* @notice Emitted when a new Interchain Gas Paymaster is set.
|
|
1003
|
+
* @param interchainGasPaymaster The address of the Interchain Gas Paymaster.
|
|
1004
|
+
*/
|
|
1005
|
+
event InterchainGasPaymasterSet(address indexed interchainGasPaymaster);
|
|
1006
|
+
|
|
1007
|
+
event InterchainSecurityModuleSet(address indexed module);
|
|
1008
|
+
|
|
1009
|
+
// ============ Modifiers ============
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* @notice Only accept messages from an Hyperlane Mailbox contract
|
|
1013
|
+
*/
|
|
1014
|
+
modifier onlyMailbox() {
|
|
1015
|
+
require(msg.sender == address(mailbox), "!mailbox");
|
|
1016
|
+
_;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* @notice Only accept addresses that at least have contract code
|
|
1021
|
+
*/
|
|
1022
|
+
modifier onlyContract(address _contract) {
|
|
1023
|
+
require(Address.isContract(_contract), "!contract");
|
|
1024
|
+
_;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// ======== Initializer =========
|
|
1028
|
+
|
|
1029
|
+
function __HyperlaneConnectionClient_initialize(address _mailbox)
|
|
1030
|
+
internal
|
|
1031
|
+
onlyInitializing
|
|
1032
|
+
{
|
|
1033
|
+
_setMailbox(_mailbox);
|
|
1034
|
+
__Ownable_init();
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
function __HyperlaneConnectionClient_initialize(
|
|
1038
|
+
address _mailbox,
|
|
1039
|
+
address _interchainGasPaymaster
|
|
1040
|
+
) internal onlyInitializing {
|
|
1041
|
+
_setInterchainGasPaymaster(_interchainGasPaymaster);
|
|
1042
|
+
__HyperlaneConnectionClient_initialize(_mailbox);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
function __HyperlaneConnectionClient_initialize(
|
|
1046
|
+
address _mailbox,
|
|
1047
|
+
address _interchainGasPaymaster,
|
|
1048
|
+
address _interchainSecurityModule
|
|
1049
|
+
) internal onlyInitializing {
|
|
1050
|
+
_setInterchainSecurityModule(_interchainSecurityModule);
|
|
1051
|
+
__HyperlaneConnectionClient_initialize(
|
|
1052
|
+
_mailbox,
|
|
1053
|
+
_interchainGasPaymaster
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
function __HyperlaneConnectionClient_initialize(
|
|
1058
|
+
address _mailbox,
|
|
1059
|
+
address _interchainGasPaymaster,
|
|
1060
|
+
address _interchainSecurityModule,
|
|
1061
|
+
address _owner
|
|
1062
|
+
) internal onlyInitializing {
|
|
1063
|
+
_setMailbox(_mailbox);
|
|
1064
|
+
_setInterchainGasPaymaster(_interchainGasPaymaster);
|
|
1065
|
+
_setInterchainSecurityModule(_interchainSecurityModule);
|
|
1066
|
+
_transferOwnership(_owner);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
// ============ External functions ============
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* @notice Sets the address of the application's Mailbox.
|
|
1073
|
+
* @param _mailbox The address of the Mailbox contract.
|
|
1074
|
+
*/
|
|
1075
|
+
function setMailbox(address _mailbox) external virtual onlyOwner {
|
|
1076
|
+
_setMailbox(_mailbox);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* @notice Sets the address of the application's InterchainGasPaymaster.
|
|
1081
|
+
* @param _interchainGasPaymaster The address of the InterchainGasPaymaster contract.
|
|
1082
|
+
*/
|
|
1083
|
+
function setInterchainGasPaymaster(address _interchainGasPaymaster)
|
|
1084
|
+
external
|
|
1085
|
+
virtual
|
|
1086
|
+
onlyOwner
|
|
1087
|
+
{
|
|
1088
|
+
_setInterchainGasPaymaster(_interchainGasPaymaster);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function setInterchainSecurityModule(address _module)
|
|
1092
|
+
external
|
|
1093
|
+
virtual
|
|
1094
|
+
onlyOwner
|
|
1095
|
+
{
|
|
1096
|
+
_setInterchainSecurityModule(_module);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// ============ Internal functions ============
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* @notice Sets the address of the application's InterchainGasPaymaster.
|
|
1103
|
+
* @param _interchainGasPaymaster The address of the InterchainGasPaymaster contract.
|
|
1104
|
+
*/
|
|
1105
|
+
function _setInterchainGasPaymaster(address _interchainGasPaymaster)
|
|
1106
|
+
internal
|
|
1107
|
+
onlyContract(_interchainGasPaymaster)
|
|
1108
|
+
{
|
|
1109
|
+
interchainGasPaymaster = IInterchainGasPaymaster(
|
|
1110
|
+
_interchainGasPaymaster
|
|
1111
|
+
);
|
|
1112
|
+
emit InterchainGasPaymasterSet(_interchainGasPaymaster);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* @notice Modify the contract the Application uses to validate Mailbox contracts
|
|
1117
|
+
* @param _mailbox The address of the mailbox contract
|
|
1118
|
+
*/
|
|
1119
|
+
function _setMailbox(address _mailbox) internal onlyContract(_mailbox) {
|
|
1120
|
+
mailbox = IMailbox(_mailbox);
|
|
1121
|
+
emit MailboxSet(_mailbox);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
function _setInterchainSecurityModule(address _module) internal {
|
|
1125
|
+
require(
|
|
1126
|
+
_module == address(0) || Address.isContract(_module),
|
|
1127
|
+
"!contract"
|
|
1128
|
+
);
|
|
1129
|
+
interchainSecurityModule = IInterchainSecurityModule(_module);
|
|
1130
|
+
emit InterchainSecurityModuleSet(_module);
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// File @hyperlane-xyz/core/interfaces/IMessageRecipient.sol@v1.0.0-beta6
|
|
1135
|
+
|
|
1136
|
+
pragma solidity >=0.6.11;
|
|
1137
|
+
|
|
1138
|
+
interface IMessageRecipient {
|
|
1139
|
+
function handle(
|
|
1140
|
+
uint32 _origin,
|
|
1141
|
+
bytes32 _sender,
|
|
1142
|
+
bytes calldata _message
|
|
1143
|
+
) external;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// File @openzeppelin/contracts/utils/structs/EnumerableSet.sol@v4.8.0
|
|
1147
|
+
|
|
1148
|
+
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
|
|
1149
|
+
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
|
|
1150
|
+
|
|
1151
|
+
pragma solidity ^0.8.0;
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* @dev Library for managing
|
|
1155
|
+
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
|
|
1156
|
+
* types.
|
|
1157
|
+
*
|
|
1158
|
+
* Sets have the following properties:
|
|
1159
|
+
*
|
|
1160
|
+
* - Elements are added, removed, and checked for existence in constant time
|
|
1161
|
+
* (O(1)).
|
|
1162
|
+
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
|
|
1163
|
+
*
|
|
1164
|
+
* ```
|
|
1165
|
+
* contract Example {
|
|
1166
|
+
* // Add the library methods
|
|
1167
|
+
* using EnumerableSet for EnumerableSet.AddressSet;
|
|
1168
|
+
*
|
|
1169
|
+
* // Declare a set state variable
|
|
1170
|
+
* EnumerableSet.AddressSet private mySet;
|
|
1171
|
+
* }
|
|
1172
|
+
* ```
|
|
1173
|
+
*
|
|
1174
|
+
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
|
|
1175
|
+
* and `uint256` (`UintSet`) are supported.
|
|
1176
|
+
*
|
|
1177
|
+
* [WARNING]
|
|
1178
|
+
* ====
|
|
1179
|
+
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
|
|
1180
|
+
* unusable.
|
|
1181
|
+
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
|
|
1182
|
+
*
|
|
1183
|
+
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
|
|
1184
|
+
* array of EnumerableSet.
|
|
1185
|
+
* ====
|
|
1186
|
+
*/
|
|
1187
|
+
library EnumerableSet {
|
|
1188
|
+
// To implement this library for multiple types with as little code
|
|
1189
|
+
// repetition as possible, we write it in terms of a generic Set type with
|
|
1190
|
+
// bytes32 values.
|
|
1191
|
+
// The Set implementation uses private functions, and user-facing
|
|
1192
|
+
// implementations (such as AddressSet) are just wrappers around the
|
|
1193
|
+
// underlying Set.
|
|
1194
|
+
// This means that we can only create new EnumerableSets for types that fit
|
|
1195
|
+
// in bytes32.
|
|
1196
|
+
|
|
1197
|
+
struct Set {
|
|
1198
|
+
// Storage of set values
|
|
1199
|
+
bytes32[] _values;
|
|
1200
|
+
// Position of the value in the `values` array, plus 1 because index 0
|
|
1201
|
+
// means a value is not in the set.
|
|
1202
|
+
mapping(bytes32 => uint256) _indexes;
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* @dev Add a value to a set. O(1).
|
|
1207
|
+
*
|
|
1208
|
+
* Returns true if the value was added to the set, that is if it was not
|
|
1209
|
+
* already present.
|
|
1210
|
+
*/
|
|
1211
|
+
function _add(Set storage set, bytes32 value) private returns (bool) {
|
|
1212
|
+
if (!_contains(set, value)) {
|
|
1213
|
+
set._values.push(value);
|
|
1214
|
+
// The value is stored at length-1, but we add 1 to all indexes
|
|
1215
|
+
// and use 0 as a sentinel value
|
|
1216
|
+
set._indexes[value] = set._values.length;
|
|
1217
|
+
return true;
|
|
1218
|
+
} else {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* @dev Removes a value from a set. O(1).
|
|
1225
|
+
*
|
|
1226
|
+
* Returns true if the value was removed from the set, that is if it was
|
|
1227
|
+
* present.
|
|
1228
|
+
*/
|
|
1229
|
+
function _remove(Set storage set, bytes32 value) private returns (bool) {
|
|
1230
|
+
// We read and store the value's index to prevent multiple reads from the same storage slot
|
|
1231
|
+
uint256 valueIndex = set._indexes[value];
|
|
1232
|
+
|
|
1233
|
+
if (valueIndex != 0) {
|
|
1234
|
+
// Equivalent to contains(set, value)
|
|
1235
|
+
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
|
|
1236
|
+
// the array, and then remove the last element (sometimes called as 'swap and pop').
|
|
1237
|
+
// This modifies the order of the array, as noted in {at}.
|
|
1238
|
+
|
|
1239
|
+
uint256 toDeleteIndex = valueIndex - 1;
|
|
1240
|
+
uint256 lastIndex = set._values.length - 1;
|
|
1241
|
+
|
|
1242
|
+
if (lastIndex != toDeleteIndex) {
|
|
1243
|
+
bytes32 lastValue = set._values[lastIndex];
|
|
1244
|
+
|
|
1245
|
+
// Move the last value to the index where the value to delete is
|
|
1246
|
+
set._values[toDeleteIndex] = lastValue;
|
|
1247
|
+
// Update the index for the moved value
|
|
1248
|
+
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// Delete the slot where the moved value was stored
|
|
1252
|
+
set._values.pop();
|
|
1253
|
+
|
|
1254
|
+
// Delete the index for the deleted slot
|
|
1255
|
+
delete set._indexes[value];
|
|
1256
|
+
|
|
1257
|
+
return true;
|
|
1258
|
+
} else {
|
|
1259
|
+
return false;
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* @dev Returns true if the value is in the set. O(1).
|
|
1265
|
+
*/
|
|
1266
|
+
function _contains(Set storage set, bytes32 value)
|
|
1267
|
+
private
|
|
1268
|
+
view
|
|
1269
|
+
returns (bool)
|
|
1270
|
+
{
|
|
1271
|
+
return set._indexes[value] != 0;
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* @dev Returns the number of values on the set. O(1).
|
|
1276
|
+
*/
|
|
1277
|
+
function _length(Set storage set) private view returns (uint256) {
|
|
1278
|
+
return set._values.length;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
|
1283
|
+
*
|
|
1284
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
1285
|
+
* array, and it may change when more values are added or removed.
|
|
1286
|
+
*
|
|
1287
|
+
* Requirements:
|
|
1288
|
+
*
|
|
1289
|
+
* - `index` must be strictly less than {length}.
|
|
1290
|
+
*/
|
|
1291
|
+
function _at(Set storage set, uint256 index)
|
|
1292
|
+
private
|
|
1293
|
+
view
|
|
1294
|
+
returns (bytes32)
|
|
1295
|
+
{
|
|
1296
|
+
return set._values[index];
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* @dev Return the entire set in an array
|
|
1301
|
+
*
|
|
1302
|
+
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
|
|
1303
|
+
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
|
|
1304
|
+
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
|
|
1305
|
+
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
|
|
1306
|
+
*/
|
|
1307
|
+
function _values(Set storage set) private view returns (bytes32[] memory) {
|
|
1308
|
+
return set._values;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// Bytes32Set
|
|
1312
|
+
|
|
1313
|
+
struct Bytes32Set {
|
|
1314
|
+
Set _inner;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* @dev Add a value to a set. O(1).
|
|
1319
|
+
*
|
|
1320
|
+
* Returns true if the value was added to the set, that is if it was not
|
|
1321
|
+
* already present.
|
|
1322
|
+
*/
|
|
1323
|
+
function add(Bytes32Set storage set, bytes32 value)
|
|
1324
|
+
internal
|
|
1325
|
+
returns (bool)
|
|
1326
|
+
{
|
|
1327
|
+
return _add(set._inner, value);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* @dev Removes a value from a set. O(1).
|
|
1332
|
+
*
|
|
1333
|
+
* Returns true if the value was removed from the set, that is if it was
|
|
1334
|
+
* present.
|
|
1335
|
+
*/
|
|
1336
|
+
function remove(Bytes32Set storage set, bytes32 value)
|
|
1337
|
+
internal
|
|
1338
|
+
returns (bool)
|
|
1339
|
+
{
|
|
1340
|
+
return _remove(set._inner, value);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* @dev Returns true if the value is in the set. O(1).
|
|
1345
|
+
*/
|
|
1346
|
+
function contains(Bytes32Set storage set, bytes32 value)
|
|
1347
|
+
internal
|
|
1348
|
+
view
|
|
1349
|
+
returns (bool)
|
|
1350
|
+
{
|
|
1351
|
+
return _contains(set._inner, value);
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* @dev Returns the number of values in the set. O(1).
|
|
1356
|
+
*/
|
|
1357
|
+
function length(Bytes32Set storage set) internal view returns (uint256) {
|
|
1358
|
+
return _length(set._inner);
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
|
1363
|
+
*
|
|
1364
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
1365
|
+
* array, and it may change when more values are added or removed.
|
|
1366
|
+
*
|
|
1367
|
+
* Requirements:
|
|
1368
|
+
*
|
|
1369
|
+
* - `index` must be strictly less than {length}.
|
|
1370
|
+
*/
|
|
1371
|
+
function at(Bytes32Set storage set, uint256 index)
|
|
1372
|
+
internal
|
|
1373
|
+
view
|
|
1374
|
+
returns (bytes32)
|
|
1375
|
+
{
|
|
1376
|
+
return _at(set._inner, index);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* @dev Return the entire set in an array
|
|
1381
|
+
*
|
|
1382
|
+
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
|
|
1383
|
+
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
|
|
1384
|
+
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
|
|
1385
|
+
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
|
|
1386
|
+
*/
|
|
1387
|
+
function values(Bytes32Set storage set)
|
|
1388
|
+
internal
|
|
1389
|
+
view
|
|
1390
|
+
returns (bytes32[] memory)
|
|
1391
|
+
{
|
|
1392
|
+
bytes32[] memory store = _values(set._inner);
|
|
1393
|
+
bytes32[] memory result;
|
|
1394
|
+
|
|
1395
|
+
/// @solidity memory-safe-assembly
|
|
1396
|
+
assembly {
|
|
1397
|
+
result := store
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
return result;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// AddressSet
|
|
1404
|
+
|
|
1405
|
+
struct AddressSet {
|
|
1406
|
+
Set _inner;
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
/**
|
|
1410
|
+
* @dev Add a value to a set. O(1).
|
|
1411
|
+
*
|
|
1412
|
+
* Returns true if the value was added to the set, that is if it was not
|
|
1413
|
+
* already present.
|
|
1414
|
+
*/
|
|
1415
|
+
function add(AddressSet storage set, address value)
|
|
1416
|
+
internal
|
|
1417
|
+
returns (bool)
|
|
1418
|
+
{
|
|
1419
|
+
return _add(set._inner, bytes32(uint256(uint160(value))));
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* @dev Removes a value from a set. O(1).
|
|
1424
|
+
*
|
|
1425
|
+
* Returns true if the value was removed from the set, that is if it was
|
|
1426
|
+
* present.
|
|
1427
|
+
*/
|
|
1428
|
+
function remove(AddressSet storage set, address value)
|
|
1429
|
+
internal
|
|
1430
|
+
returns (bool)
|
|
1431
|
+
{
|
|
1432
|
+
return _remove(set._inner, bytes32(uint256(uint160(value))));
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* @dev Returns true if the value is in the set. O(1).
|
|
1437
|
+
*/
|
|
1438
|
+
function contains(AddressSet storage set, address value)
|
|
1439
|
+
internal
|
|
1440
|
+
view
|
|
1441
|
+
returns (bool)
|
|
1442
|
+
{
|
|
1443
|
+
return _contains(set._inner, bytes32(uint256(uint160(value))));
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* @dev Returns the number of values in the set. O(1).
|
|
1448
|
+
*/
|
|
1449
|
+
function length(AddressSet storage set) internal view returns (uint256) {
|
|
1450
|
+
return _length(set._inner);
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
/**
|
|
1454
|
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
|
1455
|
+
*
|
|
1456
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
1457
|
+
* array, and it may change when more values are added or removed.
|
|
1458
|
+
*
|
|
1459
|
+
* Requirements:
|
|
1460
|
+
*
|
|
1461
|
+
* - `index` must be strictly less than {length}.
|
|
1462
|
+
*/
|
|
1463
|
+
function at(AddressSet storage set, uint256 index)
|
|
1464
|
+
internal
|
|
1465
|
+
view
|
|
1466
|
+
returns (address)
|
|
1467
|
+
{
|
|
1468
|
+
return address(uint160(uint256(_at(set._inner, index))));
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* @dev Return the entire set in an array
|
|
1473
|
+
*
|
|
1474
|
+
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
|
|
1475
|
+
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
|
|
1476
|
+
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
|
|
1477
|
+
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
|
|
1478
|
+
*/
|
|
1479
|
+
function values(AddressSet storage set)
|
|
1480
|
+
internal
|
|
1481
|
+
view
|
|
1482
|
+
returns (address[] memory)
|
|
1483
|
+
{
|
|
1484
|
+
bytes32[] memory store = _values(set._inner);
|
|
1485
|
+
address[] memory result;
|
|
1486
|
+
|
|
1487
|
+
/// @solidity memory-safe-assembly
|
|
1488
|
+
assembly {
|
|
1489
|
+
result := store
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
return result;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
// UintSet
|
|
1496
|
+
|
|
1497
|
+
struct UintSet {
|
|
1498
|
+
Set _inner;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* @dev Add a value to a set. O(1).
|
|
1503
|
+
*
|
|
1504
|
+
* Returns true if the value was added to the set, that is if it was not
|
|
1505
|
+
* already present.
|
|
1506
|
+
*/
|
|
1507
|
+
function add(UintSet storage set, uint256 value) internal returns (bool) {
|
|
1508
|
+
return _add(set._inner, bytes32(value));
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* @dev Removes a value from a set. O(1).
|
|
1513
|
+
*
|
|
1514
|
+
* Returns true if the value was removed from the set, that is if it was
|
|
1515
|
+
* present.
|
|
1516
|
+
*/
|
|
1517
|
+
function remove(UintSet storage set, uint256 value)
|
|
1518
|
+
internal
|
|
1519
|
+
returns (bool)
|
|
1520
|
+
{
|
|
1521
|
+
return _remove(set._inner, bytes32(value));
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* @dev Returns true if the value is in the set. O(1).
|
|
1526
|
+
*/
|
|
1527
|
+
function contains(UintSet storage set, uint256 value)
|
|
1528
|
+
internal
|
|
1529
|
+
view
|
|
1530
|
+
returns (bool)
|
|
1531
|
+
{
|
|
1532
|
+
return _contains(set._inner, bytes32(value));
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* @dev Returns the number of values in the set. O(1).
|
|
1537
|
+
*/
|
|
1538
|
+
function length(UintSet storage set) internal view returns (uint256) {
|
|
1539
|
+
return _length(set._inner);
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
|
1544
|
+
*
|
|
1545
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
1546
|
+
* array, and it may change when more values are added or removed.
|
|
1547
|
+
*
|
|
1548
|
+
* Requirements:
|
|
1549
|
+
*
|
|
1550
|
+
* - `index` must be strictly less than {length}.
|
|
1551
|
+
*/
|
|
1552
|
+
function at(UintSet storage set, uint256 index)
|
|
1553
|
+
internal
|
|
1554
|
+
view
|
|
1555
|
+
returns (uint256)
|
|
1556
|
+
{
|
|
1557
|
+
return uint256(_at(set._inner, index));
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* @dev Return the entire set in an array
|
|
1562
|
+
*
|
|
1563
|
+
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
|
|
1564
|
+
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
|
|
1565
|
+
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
|
|
1566
|
+
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
|
|
1567
|
+
*/
|
|
1568
|
+
function values(UintSet storage set)
|
|
1569
|
+
internal
|
|
1570
|
+
view
|
|
1571
|
+
returns (uint256[] memory)
|
|
1572
|
+
{
|
|
1573
|
+
bytes32[] memory store = _values(set._inner);
|
|
1574
|
+
uint256[] memory result;
|
|
1575
|
+
|
|
1576
|
+
/// @solidity memory-safe-assembly
|
|
1577
|
+
assembly {
|
|
1578
|
+
result := store
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
return result;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
// File @openzeppelin/contracts/utils/structs/EnumerableMap.sol@v4.8.0
|
|
1586
|
+
|
|
1587
|
+
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableMap.sol)
|
|
1588
|
+
// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.
|
|
1589
|
+
|
|
1590
|
+
pragma solidity ^0.8.0;
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* @dev Library for managing an enumerable variant of Solidity's
|
|
1594
|
+
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
|
|
1595
|
+
* type.
|
|
1596
|
+
*
|
|
1597
|
+
* Maps have the following properties:
|
|
1598
|
+
*
|
|
1599
|
+
* - Entries are added, removed, and checked for existence in constant time
|
|
1600
|
+
* (O(1)).
|
|
1601
|
+
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
|
|
1602
|
+
*
|
|
1603
|
+
* ```
|
|
1604
|
+
* contract Example {
|
|
1605
|
+
* // Add the library methods
|
|
1606
|
+
* using EnumerableMap for EnumerableMap.UintToAddressMap;
|
|
1607
|
+
*
|
|
1608
|
+
* // Declare a set state variable
|
|
1609
|
+
* EnumerableMap.UintToAddressMap private myMap;
|
|
1610
|
+
* }
|
|
1611
|
+
* ```
|
|
1612
|
+
*
|
|
1613
|
+
* The following map types are supported:
|
|
1614
|
+
*
|
|
1615
|
+
* - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
|
|
1616
|
+
* - `address -> uint256` (`AddressToUintMap`) since v4.6.0
|
|
1617
|
+
* - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0
|
|
1618
|
+
* - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
|
|
1619
|
+
* - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
|
|
1620
|
+
*
|
|
1621
|
+
* [WARNING]
|
|
1622
|
+
* ====
|
|
1623
|
+
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
|
|
1624
|
+
* unusable.
|
|
1625
|
+
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
|
|
1626
|
+
*
|
|
1627
|
+
* In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an
|
|
1628
|
+
* array of EnumerableMap.
|
|
1629
|
+
* ====
|
|
1630
|
+
*/
|
|
1631
|
+
library EnumerableMap {
|
|
1632
|
+
using EnumerableSet for EnumerableSet.Bytes32Set;
|
|
1633
|
+
|
|
1634
|
+
// To implement this library for multiple types with as little code
|
|
1635
|
+
// repetition as possible, we write it in terms of a generic Map type with
|
|
1636
|
+
// bytes32 keys and values.
|
|
1637
|
+
// The Map implementation uses private functions, and user-facing
|
|
1638
|
+
// implementations (such as Uint256ToAddressMap) are just wrappers around
|
|
1639
|
+
// the underlying Map.
|
|
1640
|
+
// This means that we can only create new EnumerableMaps for types that fit
|
|
1641
|
+
// in bytes32.
|
|
1642
|
+
|
|
1643
|
+
struct Bytes32ToBytes32Map {
|
|
1644
|
+
// Storage of keys
|
|
1645
|
+
EnumerableSet.Bytes32Set _keys;
|
|
1646
|
+
mapping(bytes32 => bytes32) _values;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* @dev Adds a key-value pair to a map, or updates the value for an existing
|
|
1651
|
+
* key. O(1).
|
|
1652
|
+
*
|
|
1653
|
+
* Returns true if the key was added to the map, that is if it was not
|
|
1654
|
+
* already present.
|
|
1655
|
+
*/
|
|
1656
|
+
function set(
|
|
1657
|
+
Bytes32ToBytes32Map storage map,
|
|
1658
|
+
bytes32 key,
|
|
1659
|
+
bytes32 value
|
|
1660
|
+
) internal returns (bool) {
|
|
1661
|
+
map._values[key] = value;
|
|
1662
|
+
return map._keys.add(key);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
/**
|
|
1666
|
+
* @dev Removes a key-value pair from a map. O(1).
|
|
1667
|
+
*
|
|
1668
|
+
* Returns true if the key was removed from the map, that is if it was present.
|
|
1669
|
+
*/
|
|
1670
|
+
function remove(Bytes32ToBytes32Map storage map, bytes32 key)
|
|
1671
|
+
internal
|
|
1672
|
+
returns (bool)
|
|
1673
|
+
{
|
|
1674
|
+
delete map._values[key];
|
|
1675
|
+
return map._keys.remove(key);
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
/**
|
|
1679
|
+
* @dev Returns true if the key is in the map. O(1).
|
|
1680
|
+
*/
|
|
1681
|
+
function contains(Bytes32ToBytes32Map storage map, bytes32 key)
|
|
1682
|
+
internal
|
|
1683
|
+
view
|
|
1684
|
+
returns (bool)
|
|
1685
|
+
{
|
|
1686
|
+
return map._keys.contains(key);
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* @dev Returns the number of key-value pairs in the map. O(1).
|
|
1691
|
+
*/
|
|
1692
|
+
function length(Bytes32ToBytes32Map storage map)
|
|
1693
|
+
internal
|
|
1694
|
+
view
|
|
1695
|
+
returns (uint256)
|
|
1696
|
+
{
|
|
1697
|
+
return map._keys.length();
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
/**
|
|
1701
|
+
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
|
|
1702
|
+
*
|
|
1703
|
+
* Note that there are no guarantees on the ordering of entries inside the
|
|
1704
|
+
* array, and it may change when more entries are added or removed.
|
|
1705
|
+
*
|
|
1706
|
+
* Requirements:
|
|
1707
|
+
*
|
|
1708
|
+
* - `index` must be strictly less than {length}.
|
|
1709
|
+
*/
|
|
1710
|
+
function at(Bytes32ToBytes32Map storage map, uint256 index)
|
|
1711
|
+
internal
|
|
1712
|
+
view
|
|
1713
|
+
returns (bytes32, bytes32)
|
|
1714
|
+
{
|
|
1715
|
+
bytes32 key = map._keys.at(index);
|
|
1716
|
+
return (key, map._values[key]);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* @dev Tries to returns the value associated with `key`. O(1).
|
|
1721
|
+
* Does not revert if `key` is not in the map.
|
|
1722
|
+
*/
|
|
1723
|
+
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key)
|
|
1724
|
+
internal
|
|
1725
|
+
view
|
|
1726
|
+
returns (bool, bytes32)
|
|
1727
|
+
{
|
|
1728
|
+
bytes32 value = map._values[key];
|
|
1729
|
+
if (value == bytes32(0)) {
|
|
1730
|
+
return (contains(map, key), bytes32(0));
|
|
1731
|
+
} else {
|
|
1732
|
+
return (true, value);
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/**
|
|
1737
|
+
* @dev Returns the value associated with `key`. O(1).
|
|
1738
|
+
*
|
|
1739
|
+
* Requirements:
|
|
1740
|
+
*
|
|
1741
|
+
* - `key` must be in the map.
|
|
1742
|
+
*/
|
|
1743
|
+
function get(Bytes32ToBytes32Map storage map, bytes32 key)
|
|
1744
|
+
internal
|
|
1745
|
+
view
|
|
1746
|
+
returns (bytes32)
|
|
1747
|
+
{
|
|
1748
|
+
bytes32 value = map._values[key];
|
|
1749
|
+
require(
|
|
1750
|
+
value != 0 || contains(map, key),
|
|
1751
|
+
"EnumerableMap: nonexistent key"
|
|
1752
|
+
);
|
|
1753
|
+
return value;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* @dev Same as {get}, with a custom error message when `key` is not in the map.
|
|
1758
|
+
*
|
|
1759
|
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
|
1760
|
+
* message unnecessarily. For custom revert reasons use {tryGet}.
|
|
1761
|
+
*/
|
|
1762
|
+
function get(
|
|
1763
|
+
Bytes32ToBytes32Map storage map,
|
|
1764
|
+
bytes32 key,
|
|
1765
|
+
string memory errorMessage
|
|
1766
|
+
) internal view returns (bytes32) {
|
|
1767
|
+
bytes32 value = map._values[key];
|
|
1768
|
+
require(value != 0 || contains(map, key), errorMessage);
|
|
1769
|
+
return value;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
// UintToUintMap
|
|
1773
|
+
|
|
1774
|
+
struct UintToUintMap {
|
|
1775
|
+
Bytes32ToBytes32Map _inner;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* @dev Adds a key-value pair to a map, or updates the value for an existing
|
|
1780
|
+
* key. O(1).
|
|
1781
|
+
*
|
|
1782
|
+
* Returns true if the key was added to the map, that is if it was not
|
|
1783
|
+
* already present.
|
|
1784
|
+
*/
|
|
1785
|
+
function set(
|
|
1786
|
+
UintToUintMap storage map,
|
|
1787
|
+
uint256 key,
|
|
1788
|
+
uint256 value
|
|
1789
|
+
) internal returns (bool) {
|
|
1790
|
+
return set(map._inner, bytes32(key), bytes32(value));
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* @dev Removes a value from a set. O(1).
|
|
1795
|
+
*
|
|
1796
|
+
* Returns true if the key was removed from the map, that is if it was present.
|
|
1797
|
+
*/
|
|
1798
|
+
function remove(UintToUintMap storage map, uint256 key)
|
|
1799
|
+
internal
|
|
1800
|
+
returns (bool)
|
|
1801
|
+
{
|
|
1802
|
+
return remove(map._inner, bytes32(key));
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
/**
|
|
1806
|
+
* @dev Returns true if the key is in the map. O(1).
|
|
1807
|
+
*/
|
|
1808
|
+
function contains(UintToUintMap storage map, uint256 key)
|
|
1809
|
+
internal
|
|
1810
|
+
view
|
|
1811
|
+
returns (bool)
|
|
1812
|
+
{
|
|
1813
|
+
return contains(map._inner, bytes32(key));
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* @dev Returns the number of elements in the map. O(1).
|
|
1818
|
+
*/
|
|
1819
|
+
function length(UintToUintMap storage map) internal view returns (uint256) {
|
|
1820
|
+
return length(map._inner);
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* @dev Returns the element stored at position `index` in the set. O(1).
|
|
1825
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
1826
|
+
* array, and it may change when more values are added or removed.
|
|
1827
|
+
*
|
|
1828
|
+
* Requirements:
|
|
1829
|
+
*
|
|
1830
|
+
* - `index` must be strictly less than {length}.
|
|
1831
|
+
*/
|
|
1832
|
+
function at(UintToUintMap storage map, uint256 index)
|
|
1833
|
+
internal
|
|
1834
|
+
view
|
|
1835
|
+
returns (uint256, uint256)
|
|
1836
|
+
{
|
|
1837
|
+
(bytes32 key, bytes32 value) = at(map._inner, index);
|
|
1838
|
+
return (uint256(key), uint256(value));
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
/**
|
|
1842
|
+
* @dev Tries to returns the value associated with `key`. O(1).
|
|
1843
|
+
* Does not revert if `key` is not in the map.
|
|
1844
|
+
*/
|
|
1845
|
+
function tryGet(UintToUintMap storage map, uint256 key)
|
|
1846
|
+
internal
|
|
1847
|
+
view
|
|
1848
|
+
returns (bool, uint256)
|
|
1849
|
+
{
|
|
1850
|
+
(bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
|
|
1851
|
+
return (success, uint256(value));
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
/**
|
|
1855
|
+
* @dev Returns the value associated with `key`. O(1).
|
|
1856
|
+
*
|
|
1857
|
+
* Requirements:
|
|
1858
|
+
*
|
|
1859
|
+
* - `key` must be in the map.
|
|
1860
|
+
*/
|
|
1861
|
+
function get(UintToUintMap storage map, uint256 key)
|
|
1862
|
+
internal
|
|
1863
|
+
view
|
|
1864
|
+
returns (uint256)
|
|
1865
|
+
{
|
|
1866
|
+
return uint256(get(map._inner, bytes32(key)));
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
/**
|
|
1870
|
+
* @dev Same as {get}, with a custom error message when `key` is not in the map.
|
|
1871
|
+
*
|
|
1872
|
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
|
1873
|
+
* message unnecessarily. For custom revert reasons use {tryGet}.
|
|
1874
|
+
*/
|
|
1875
|
+
function get(
|
|
1876
|
+
UintToUintMap storage map,
|
|
1877
|
+
uint256 key,
|
|
1878
|
+
string memory errorMessage
|
|
1879
|
+
) internal view returns (uint256) {
|
|
1880
|
+
return uint256(get(map._inner, bytes32(key), errorMessage));
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
// UintToAddressMap
|
|
1884
|
+
|
|
1885
|
+
struct UintToAddressMap {
|
|
1886
|
+
Bytes32ToBytes32Map _inner;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
/**
|
|
1890
|
+
* @dev Adds a key-value pair to a map, or updates the value for an existing
|
|
1891
|
+
* key. O(1).
|
|
1892
|
+
*
|
|
1893
|
+
* Returns true if the key was added to the map, that is if it was not
|
|
1894
|
+
* already present.
|
|
1895
|
+
*/
|
|
1896
|
+
function set(
|
|
1897
|
+
UintToAddressMap storage map,
|
|
1898
|
+
uint256 key,
|
|
1899
|
+
address value
|
|
1900
|
+
) internal returns (bool) {
|
|
1901
|
+
return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
/**
|
|
1905
|
+
* @dev Removes a value from a set. O(1).
|
|
1906
|
+
*
|
|
1907
|
+
* Returns true if the key was removed from the map, that is if it was present.
|
|
1908
|
+
*/
|
|
1909
|
+
function remove(UintToAddressMap storage map, uint256 key)
|
|
1910
|
+
internal
|
|
1911
|
+
returns (bool)
|
|
1912
|
+
{
|
|
1913
|
+
return remove(map._inner, bytes32(key));
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
/**
|
|
1917
|
+
* @dev Returns true if the key is in the map. O(1).
|
|
1918
|
+
*/
|
|
1919
|
+
function contains(UintToAddressMap storage map, uint256 key)
|
|
1920
|
+
internal
|
|
1921
|
+
view
|
|
1922
|
+
returns (bool)
|
|
1923
|
+
{
|
|
1924
|
+
return contains(map._inner, bytes32(key));
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
/**
|
|
1928
|
+
* @dev Returns the number of elements in the map. O(1).
|
|
1929
|
+
*/
|
|
1930
|
+
function length(UintToAddressMap storage map)
|
|
1931
|
+
internal
|
|
1932
|
+
view
|
|
1933
|
+
returns (uint256)
|
|
1934
|
+
{
|
|
1935
|
+
return length(map._inner);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* @dev Returns the element stored at position `index` in the set. O(1).
|
|
1940
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
1941
|
+
* array, and it may change when more values are added or removed.
|
|
1942
|
+
*
|
|
1943
|
+
* Requirements:
|
|
1944
|
+
*
|
|
1945
|
+
* - `index` must be strictly less than {length}.
|
|
1946
|
+
*/
|
|
1947
|
+
function at(UintToAddressMap storage map, uint256 index)
|
|
1948
|
+
internal
|
|
1949
|
+
view
|
|
1950
|
+
returns (uint256, address)
|
|
1951
|
+
{
|
|
1952
|
+
(bytes32 key, bytes32 value) = at(map._inner, index);
|
|
1953
|
+
return (uint256(key), address(uint160(uint256(value))));
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
/**
|
|
1957
|
+
* @dev Tries to returns the value associated with `key`. O(1).
|
|
1958
|
+
* Does not revert if `key` is not in the map.
|
|
1959
|
+
*/
|
|
1960
|
+
function tryGet(UintToAddressMap storage map, uint256 key)
|
|
1961
|
+
internal
|
|
1962
|
+
view
|
|
1963
|
+
returns (bool, address)
|
|
1964
|
+
{
|
|
1965
|
+
(bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
|
|
1966
|
+
return (success, address(uint160(uint256(value))));
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* @dev Returns the value associated with `key`. O(1).
|
|
1971
|
+
*
|
|
1972
|
+
* Requirements:
|
|
1973
|
+
*
|
|
1974
|
+
* - `key` must be in the map.
|
|
1975
|
+
*/
|
|
1976
|
+
function get(UintToAddressMap storage map, uint256 key)
|
|
1977
|
+
internal
|
|
1978
|
+
view
|
|
1979
|
+
returns (address)
|
|
1980
|
+
{
|
|
1981
|
+
return address(uint160(uint256(get(map._inner, bytes32(key)))));
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* @dev Same as {get}, with a custom error message when `key` is not in the map.
|
|
1986
|
+
*
|
|
1987
|
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
|
1988
|
+
* message unnecessarily. For custom revert reasons use {tryGet}.
|
|
1989
|
+
*/
|
|
1990
|
+
function get(
|
|
1991
|
+
UintToAddressMap storage map,
|
|
1992
|
+
uint256 key,
|
|
1993
|
+
string memory errorMessage
|
|
1994
|
+
) internal view returns (address) {
|
|
1995
|
+
return
|
|
1996
|
+
address(
|
|
1997
|
+
uint160(uint256(get(map._inner, bytes32(key), errorMessage)))
|
|
1998
|
+
);
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// AddressToUintMap
|
|
2002
|
+
|
|
2003
|
+
struct AddressToUintMap {
|
|
2004
|
+
Bytes32ToBytes32Map _inner;
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* @dev Adds a key-value pair to a map, or updates the value for an existing
|
|
2009
|
+
* key. O(1).
|
|
2010
|
+
*
|
|
2011
|
+
* Returns true if the key was added to the map, that is if it was not
|
|
2012
|
+
* already present.
|
|
2013
|
+
*/
|
|
2014
|
+
function set(
|
|
2015
|
+
AddressToUintMap storage map,
|
|
2016
|
+
address key,
|
|
2017
|
+
uint256 value
|
|
2018
|
+
) internal returns (bool) {
|
|
2019
|
+
return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* @dev Removes a value from a set. O(1).
|
|
2024
|
+
*
|
|
2025
|
+
* Returns true if the key was removed from the map, that is if it was present.
|
|
2026
|
+
*/
|
|
2027
|
+
function remove(AddressToUintMap storage map, address key)
|
|
2028
|
+
internal
|
|
2029
|
+
returns (bool)
|
|
2030
|
+
{
|
|
2031
|
+
return remove(map._inner, bytes32(uint256(uint160(key))));
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/**
|
|
2035
|
+
* @dev Returns true if the key is in the map. O(1).
|
|
2036
|
+
*/
|
|
2037
|
+
function contains(AddressToUintMap storage map, address key)
|
|
2038
|
+
internal
|
|
2039
|
+
view
|
|
2040
|
+
returns (bool)
|
|
2041
|
+
{
|
|
2042
|
+
return contains(map._inner, bytes32(uint256(uint160(key))));
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
/**
|
|
2046
|
+
* @dev Returns the number of elements in the map. O(1).
|
|
2047
|
+
*/
|
|
2048
|
+
function length(AddressToUintMap storage map)
|
|
2049
|
+
internal
|
|
2050
|
+
view
|
|
2051
|
+
returns (uint256)
|
|
2052
|
+
{
|
|
2053
|
+
return length(map._inner);
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
/**
|
|
2057
|
+
* @dev Returns the element stored at position `index` in the set. O(1).
|
|
2058
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
2059
|
+
* array, and it may change when more values are added or removed.
|
|
2060
|
+
*
|
|
2061
|
+
* Requirements:
|
|
2062
|
+
*
|
|
2063
|
+
* - `index` must be strictly less than {length}.
|
|
2064
|
+
*/
|
|
2065
|
+
function at(AddressToUintMap storage map, uint256 index)
|
|
2066
|
+
internal
|
|
2067
|
+
view
|
|
2068
|
+
returns (address, uint256)
|
|
2069
|
+
{
|
|
2070
|
+
(bytes32 key, bytes32 value) = at(map._inner, index);
|
|
2071
|
+
return (address(uint160(uint256(key))), uint256(value));
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* @dev Tries to returns the value associated with `key`. O(1).
|
|
2076
|
+
* Does not revert if `key` is not in the map.
|
|
2077
|
+
*/
|
|
2078
|
+
function tryGet(AddressToUintMap storage map, address key)
|
|
2079
|
+
internal
|
|
2080
|
+
view
|
|
2081
|
+
returns (bool, uint256)
|
|
2082
|
+
{
|
|
2083
|
+
(bool success, bytes32 value) = tryGet(
|
|
2084
|
+
map._inner,
|
|
2085
|
+
bytes32(uint256(uint160(key)))
|
|
2086
|
+
);
|
|
2087
|
+
return (success, uint256(value));
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* @dev Returns the value associated with `key`. O(1).
|
|
2092
|
+
*
|
|
2093
|
+
* Requirements:
|
|
2094
|
+
*
|
|
2095
|
+
* - `key` must be in the map.
|
|
2096
|
+
*/
|
|
2097
|
+
function get(AddressToUintMap storage map, address key)
|
|
2098
|
+
internal
|
|
2099
|
+
view
|
|
2100
|
+
returns (uint256)
|
|
2101
|
+
{
|
|
2102
|
+
return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
/**
|
|
2106
|
+
* @dev Same as {get}, with a custom error message when `key` is not in the map.
|
|
2107
|
+
*
|
|
2108
|
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
|
2109
|
+
* message unnecessarily. For custom revert reasons use {tryGet}.
|
|
2110
|
+
*/
|
|
2111
|
+
function get(
|
|
2112
|
+
AddressToUintMap storage map,
|
|
2113
|
+
address key,
|
|
2114
|
+
string memory errorMessage
|
|
2115
|
+
) internal view returns (uint256) {
|
|
2116
|
+
return
|
|
2117
|
+
uint256(
|
|
2118
|
+
get(map._inner, bytes32(uint256(uint160(key))), errorMessage)
|
|
2119
|
+
);
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
// Bytes32ToUintMap
|
|
2123
|
+
|
|
2124
|
+
struct Bytes32ToUintMap {
|
|
2125
|
+
Bytes32ToBytes32Map _inner;
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
/**
|
|
2129
|
+
* @dev Adds a key-value pair to a map, or updates the value for an existing
|
|
2130
|
+
* key. O(1).
|
|
2131
|
+
*
|
|
2132
|
+
* Returns true if the key was added to the map, that is if it was not
|
|
2133
|
+
* already present.
|
|
2134
|
+
*/
|
|
2135
|
+
function set(
|
|
2136
|
+
Bytes32ToUintMap storage map,
|
|
2137
|
+
bytes32 key,
|
|
2138
|
+
uint256 value
|
|
2139
|
+
) internal returns (bool) {
|
|
2140
|
+
return set(map._inner, key, bytes32(value));
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
/**
|
|
2144
|
+
* @dev Removes a value from a set. O(1).
|
|
2145
|
+
*
|
|
2146
|
+
* Returns true if the key was removed from the map, that is if it was present.
|
|
2147
|
+
*/
|
|
2148
|
+
function remove(Bytes32ToUintMap storage map, bytes32 key)
|
|
2149
|
+
internal
|
|
2150
|
+
returns (bool)
|
|
2151
|
+
{
|
|
2152
|
+
return remove(map._inner, key);
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
/**
|
|
2156
|
+
* @dev Returns true if the key is in the map. O(1).
|
|
2157
|
+
*/
|
|
2158
|
+
function contains(Bytes32ToUintMap storage map, bytes32 key)
|
|
2159
|
+
internal
|
|
2160
|
+
view
|
|
2161
|
+
returns (bool)
|
|
2162
|
+
{
|
|
2163
|
+
return contains(map._inner, key);
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
/**
|
|
2167
|
+
* @dev Returns the number of elements in the map. O(1).
|
|
2168
|
+
*/
|
|
2169
|
+
function length(Bytes32ToUintMap storage map)
|
|
2170
|
+
internal
|
|
2171
|
+
view
|
|
2172
|
+
returns (uint256)
|
|
2173
|
+
{
|
|
2174
|
+
return length(map._inner);
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* @dev Returns the element stored at position `index` in the set. O(1).
|
|
2179
|
+
* Note that there are no guarantees on the ordering of values inside the
|
|
2180
|
+
* array, and it may change when more values are added or removed.
|
|
2181
|
+
*
|
|
2182
|
+
* Requirements:
|
|
2183
|
+
*
|
|
2184
|
+
* - `index` must be strictly less than {length}.
|
|
2185
|
+
*/
|
|
2186
|
+
function at(Bytes32ToUintMap storage map, uint256 index)
|
|
2187
|
+
internal
|
|
2188
|
+
view
|
|
2189
|
+
returns (bytes32, uint256)
|
|
2190
|
+
{
|
|
2191
|
+
(bytes32 key, bytes32 value) = at(map._inner, index);
|
|
2192
|
+
return (key, uint256(value));
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* @dev Tries to returns the value associated with `key`. O(1).
|
|
2197
|
+
* Does not revert if `key` is not in the map.
|
|
2198
|
+
*/
|
|
2199
|
+
function tryGet(Bytes32ToUintMap storage map, bytes32 key)
|
|
2200
|
+
internal
|
|
2201
|
+
view
|
|
2202
|
+
returns (bool, uint256)
|
|
2203
|
+
{
|
|
2204
|
+
(bool success, bytes32 value) = tryGet(map._inner, key);
|
|
2205
|
+
return (success, uint256(value));
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
/**
|
|
2209
|
+
* @dev Returns the value associated with `key`. O(1).
|
|
2210
|
+
*
|
|
2211
|
+
* Requirements:
|
|
2212
|
+
*
|
|
2213
|
+
* - `key` must be in the map.
|
|
2214
|
+
*/
|
|
2215
|
+
function get(Bytes32ToUintMap storage map, bytes32 key)
|
|
2216
|
+
internal
|
|
2217
|
+
view
|
|
2218
|
+
returns (uint256)
|
|
2219
|
+
{
|
|
2220
|
+
return uint256(get(map._inner, key));
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
/**
|
|
2224
|
+
* @dev Same as {get}, with a custom error message when `key` is not in the map.
|
|
2225
|
+
*
|
|
2226
|
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
|
2227
|
+
* message unnecessarily. For custom revert reasons use {tryGet}.
|
|
2228
|
+
*/
|
|
2229
|
+
function get(
|
|
2230
|
+
Bytes32ToUintMap storage map,
|
|
2231
|
+
bytes32 key,
|
|
2232
|
+
string memory errorMessage
|
|
2233
|
+
) internal view returns (uint256) {
|
|
2234
|
+
return uint256(get(map._inner, key, errorMessage));
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2238
|
+
// File @hyperlane-xyz/core/contracts/libs/EnumerableMapExtended.sol@v1.0.0-beta6
|
|
2239
|
+
|
|
2240
|
+
pragma solidity >=0.6.11;
|
|
2241
|
+
|
|
2242
|
+
// ============ External Imports ============
|
|
2243
|
+
|
|
2244
|
+
// extends EnumerableMap with uint256 => bytes32 type
|
|
2245
|
+
// modelled after https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/utils/structs/EnumerableMap.sol
|
|
2246
|
+
library EnumerableMapExtended {
|
|
2247
|
+
using EnumerableMap for EnumerableMap.Bytes32ToBytes32Map;
|
|
2248
|
+
|
|
2249
|
+
struct UintToBytes32Map {
|
|
2250
|
+
EnumerableMap.Bytes32ToBytes32Map _inner;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
// ============ Library Functions ============
|
|
2254
|
+
function keys(UintToBytes32Map storage map)
|
|
2255
|
+
internal
|
|
2256
|
+
view
|
|
2257
|
+
returns (bytes32[] storage)
|
|
2258
|
+
{
|
|
2259
|
+
return map._inner._keys._inner._values;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
function set(
|
|
2263
|
+
UintToBytes32Map storage map,
|
|
2264
|
+
uint256 key,
|
|
2265
|
+
bytes32 value
|
|
2266
|
+
) internal {
|
|
2267
|
+
map._inner.set(bytes32(key), value);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
function get(UintToBytes32Map storage map, uint256 key)
|
|
2271
|
+
internal
|
|
2272
|
+
view
|
|
2273
|
+
returns (bytes32)
|
|
2274
|
+
{
|
|
2275
|
+
return map._inner.get(bytes32(key));
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
function remove(UintToBytes32Map storage map, uint256 key)
|
|
2279
|
+
internal
|
|
2280
|
+
returns (bool)
|
|
2281
|
+
{
|
|
2282
|
+
return map._inner.remove(bytes32(key));
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
function contains(UintToBytes32Map storage map, uint256 key)
|
|
2286
|
+
internal
|
|
2287
|
+
view
|
|
2288
|
+
returns (bool)
|
|
2289
|
+
{
|
|
2290
|
+
return map._inner.contains(bytes32(key));
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
function length(UintToBytes32Map storage map)
|
|
2294
|
+
internal
|
|
2295
|
+
view
|
|
2296
|
+
returns (uint256)
|
|
2297
|
+
{
|
|
2298
|
+
return map._inner.length();
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
function at(UintToBytes32Map storage map, uint256 index)
|
|
2302
|
+
internal
|
|
2303
|
+
view
|
|
2304
|
+
returns (uint256, bytes32)
|
|
2305
|
+
{
|
|
2306
|
+
(bytes32 key, bytes32 value) = map._inner.at(index);
|
|
2307
|
+
return (uint256(key), value);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// File @hyperlane-xyz/core/contracts/Router.sol@v1.0.0-beta6
|
|
2312
|
+
|
|
2313
|
+
pragma solidity >=0.6.11;
|
|
2314
|
+
|
|
2315
|
+
// ============ Internal Imports ============
|
|
2316
|
+
|
|
2317
|
+
abstract contract Router is HyperlaneConnectionClient, IMessageRecipient {
|
|
2318
|
+
using EnumerableMapExtended for EnumerableMapExtended.UintToBytes32Map;
|
|
2319
|
+
|
|
2320
|
+
string constant NO_ROUTER_ENROLLED_REVERT_MESSAGE =
|
|
2321
|
+
"No router enrolled for domain. Did you specify the right domain ID?";
|
|
2322
|
+
|
|
2323
|
+
// ============ Mutable Storage ============
|
|
2324
|
+
EnumerableMapExtended.UintToBytes32Map internal _routers;
|
|
2325
|
+
uint256[49] private __GAP; // gap for upgrade safety
|
|
2326
|
+
|
|
2327
|
+
// ============ Events ============
|
|
2328
|
+
|
|
2329
|
+
/**
|
|
2330
|
+
* @notice Emitted when a router is set.
|
|
2331
|
+
* @param domain The domain of the new router
|
|
2332
|
+
* @param router The address of the new router
|
|
2333
|
+
*/
|
|
2334
|
+
event RemoteRouterEnrolled(uint32 indexed domain, bytes32 indexed router);
|
|
2335
|
+
|
|
2336
|
+
// ============ Modifiers ============
|
|
2337
|
+
/**
|
|
2338
|
+
* @notice Only accept messages from a remote Router contract
|
|
2339
|
+
* @param _origin The domain the message is coming from
|
|
2340
|
+
* @param _router The address the message is coming from
|
|
2341
|
+
*/
|
|
2342
|
+
modifier onlyRemoteRouter(uint32 _origin, bytes32 _router) {
|
|
2343
|
+
require(
|
|
2344
|
+
_isRemoteRouter(_origin, _router),
|
|
2345
|
+
NO_ROUTER_ENROLLED_REVERT_MESSAGE
|
|
2346
|
+
);
|
|
2347
|
+
_;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
// ============ External functions ============
|
|
2351
|
+
function domains() external view returns (uint32[] memory) {
|
|
2352
|
+
bytes32[] storage rawKeys = _routers.keys();
|
|
2353
|
+
uint32[] memory keys = new uint32[](rawKeys.length);
|
|
2354
|
+
for (uint256 i = 0; i < rawKeys.length; i++) {
|
|
2355
|
+
keys[i] = uint32(uint256(rawKeys[i]));
|
|
2356
|
+
}
|
|
2357
|
+
return keys;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
function routers(uint32 _domain) public view returns (bytes32) {
|
|
2361
|
+
if (_routers.contains(_domain)) {
|
|
2362
|
+
return _routers.get(_domain);
|
|
2363
|
+
} else {
|
|
2364
|
+
return bytes32(0); // for backwards compatibility with storage mapping
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/**
|
|
2369
|
+
* @notice Register the address of a Router contract for the same Application on a remote chain
|
|
2370
|
+
* @param _domain The domain of the remote Application Router
|
|
2371
|
+
* @param _router The address of the remote Application Router
|
|
2372
|
+
*/
|
|
2373
|
+
function enrollRemoteRouter(uint32 _domain, bytes32 _router)
|
|
2374
|
+
external
|
|
2375
|
+
virtual
|
|
2376
|
+
onlyOwner
|
|
2377
|
+
{
|
|
2378
|
+
_enrollRemoteRouter(_domain, _router);
|
|
2379
|
+
}
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* @notice Batch version of `enrollRemoteRouter`
|
|
2383
|
+
* @param _domains The domaisn of the remote Application Routers
|
|
2384
|
+
* @param _addresses The addresses of the remote Application Routers
|
|
2385
|
+
*/
|
|
2386
|
+
function enrollRemoteRouters(
|
|
2387
|
+
uint32[] calldata _domains,
|
|
2388
|
+
bytes32[] calldata _addresses
|
|
2389
|
+
) external virtual onlyOwner {
|
|
2390
|
+
require(_domains.length == _addresses.length, "!length");
|
|
2391
|
+
for (uint256 i = 0; i < _domains.length; i += 1) {
|
|
2392
|
+
_enrollRemoteRouter(_domains[i], _addresses[i]);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
/**
|
|
2397
|
+
* @notice Handles an incoming message
|
|
2398
|
+
* @param _origin The origin domain
|
|
2399
|
+
* @param _sender The sender address
|
|
2400
|
+
* @param _message The message
|
|
2401
|
+
*/
|
|
2402
|
+
function handle(
|
|
2403
|
+
uint32 _origin,
|
|
2404
|
+
bytes32 _sender,
|
|
2405
|
+
bytes calldata _message
|
|
2406
|
+
) external virtual override onlyMailbox onlyRemoteRouter(_origin, _sender) {
|
|
2407
|
+
// TODO: callbacks on success/failure
|
|
2408
|
+
_handle(_origin, _sender, _message);
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
// ============ Virtual functions ============
|
|
2412
|
+
function _handle(
|
|
2413
|
+
uint32 _origin,
|
|
2414
|
+
bytes32 _sender,
|
|
2415
|
+
bytes calldata _message
|
|
2416
|
+
) internal virtual;
|
|
2417
|
+
|
|
2418
|
+
// ============ Internal functions ============
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* @notice Set the router for a given domain
|
|
2422
|
+
* @param _domain The domain
|
|
2423
|
+
* @param _address The new router
|
|
2424
|
+
*/
|
|
2425
|
+
function _enrollRemoteRouter(uint32 _domain, bytes32 _address) internal {
|
|
2426
|
+
_routers.set(_domain, _address);
|
|
2427
|
+
emit RemoteRouterEnrolled(_domain, _address);
|
|
2428
|
+
}
|
|
2429
|
+
|
|
2430
|
+
/**
|
|
2431
|
+
* @notice Return true if the given domain / router is the address of a remote Application Router
|
|
2432
|
+
* @param _domain The domain of the potential remote Application Router
|
|
2433
|
+
* @param _address The address of the potential remote Application Router
|
|
2434
|
+
*/
|
|
2435
|
+
function _isRemoteRouter(uint32 _domain, bytes32 _address)
|
|
2436
|
+
internal
|
|
2437
|
+
view
|
|
2438
|
+
returns (bool)
|
|
2439
|
+
{
|
|
2440
|
+
return routers(_domain) == _address;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
/**
|
|
2444
|
+
* @notice Assert that the given domain has a Application Router registered and return its address
|
|
2445
|
+
* @param _domain The domain of the chain for which to get the Application Router
|
|
2446
|
+
* @return _router The address of the remote Application Router on _domain
|
|
2447
|
+
*/
|
|
2448
|
+
function _mustHaveRemoteRouter(uint32 _domain)
|
|
2449
|
+
internal
|
|
2450
|
+
view
|
|
2451
|
+
returns (bytes32 _router)
|
|
2452
|
+
{
|
|
2453
|
+
_router = routers(_domain);
|
|
2454
|
+
require(_router != bytes32(0), NO_ROUTER_ENROLLED_REVERT_MESSAGE);
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
/**
|
|
2458
|
+
* @notice Dispatches a message to an enrolled router via the local router's Mailbox
|
|
2459
|
+
* and pays for it to be relayed to the destination.
|
|
2460
|
+
* @dev Reverts if there is no enrolled router for _destinationDomain.
|
|
2461
|
+
* @param _destinationDomain The domain of the chain to which to send the message.
|
|
2462
|
+
* @param _messageBody Raw bytes content of message.
|
|
2463
|
+
* @param _gasAmount The amount of destination gas for the message that is requested via the InterchainGasPaymaster.
|
|
2464
|
+
* @param _gasPayment The amount of native tokens to pay for the message to be relayed.
|
|
2465
|
+
* @param _gasPaymentRefundAddress The address to refund any gas overpayment to.
|
|
2466
|
+
*/
|
|
2467
|
+
function _dispatchWithGas(
|
|
2468
|
+
uint32 _destinationDomain,
|
|
2469
|
+
bytes memory _messageBody,
|
|
2470
|
+
uint256 _gasAmount,
|
|
2471
|
+
uint256 _gasPayment,
|
|
2472
|
+
address _gasPaymentRefundAddress
|
|
2473
|
+
) internal returns (bytes32 _messageId) {
|
|
2474
|
+
_messageId = _dispatch(_destinationDomain, _messageBody);
|
|
2475
|
+
// Call the IGP even if the gas payment is zero. This is to support on-chain
|
|
2476
|
+
// fee quoting in IGPs, which should always revert if gas payment is insufficient.
|
|
2477
|
+
interchainGasPaymaster.payForGas{value: _gasPayment}(
|
|
2478
|
+
_messageId,
|
|
2479
|
+
_destinationDomain,
|
|
2480
|
+
_gasAmount,
|
|
2481
|
+
_gasPaymentRefundAddress
|
|
2482
|
+
);
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
/**
|
|
2486
|
+
* @notice Dispatches a message to an enrolled router via the provided Mailbox.
|
|
2487
|
+
* @dev Does not pay interchain gas.
|
|
2488
|
+
* @dev Reverts if there is no enrolled router for _destinationDomain.
|
|
2489
|
+
* @param _destinationDomain The domain of the chain to which to send the message.
|
|
2490
|
+
* @param _messageBody Raw bytes content of message.
|
|
2491
|
+
*/
|
|
2492
|
+
function _dispatch(uint32 _destinationDomain, bytes memory _messageBody)
|
|
2493
|
+
internal
|
|
2494
|
+
virtual
|
|
2495
|
+
returns (bytes32)
|
|
2496
|
+
{
|
|
2497
|
+
// Ensure that destination chain has an enrolled router.
|
|
2498
|
+
bytes32 _router = _mustHaveRemoteRouter(_destinationDomain);
|
|
2499
|
+
return mailbox.dispatch(_destinationDomain, _router, _messageBody);
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
// File contracts/HelloWorld.sol
|
|
2504
|
+
|
|
2505
|
+
pragma solidity ^0.8.13;
|
|
2506
|
+
|
|
2507
|
+
// ============ External Imports ============
|
|
2508
|
+
|
|
2509
|
+
/*
|
|
2510
|
+
* @title The Hello World App
|
|
2511
|
+
* @dev You can use this simple app as a starting point for your own application.
|
|
2512
|
+
*/
|
|
2513
|
+
contract HelloWorld is Router {
|
|
2514
|
+
// A counter of how many messages have been sent from this contract.
|
|
2515
|
+
uint256 public sent;
|
|
2516
|
+
// A counter of how many messages have been received by this contract.
|
|
2517
|
+
uint256 public received;
|
|
2518
|
+
|
|
2519
|
+
// Keyed by domain, a counter of how many messages that have been sent
|
|
2520
|
+
// from this contract to the domain.
|
|
2521
|
+
mapping(uint32 => uint256) public sentTo;
|
|
2522
|
+
// Keyed by domain, a counter of how many messages that have been received
|
|
2523
|
+
// by this contract from the domain.
|
|
2524
|
+
mapping(uint32 => uint256) public receivedFrom;
|
|
2525
|
+
|
|
2526
|
+
// ============ Events ============
|
|
2527
|
+
event SentHelloWorld(
|
|
2528
|
+
uint32 indexed origin,
|
|
2529
|
+
uint32 indexed destination,
|
|
2530
|
+
string message
|
|
2531
|
+
);
|
|
2532
|
+
event ReceivedHelloWorld(
|
|
2533
|
+
uint32 indexed origin,
|
|
2534
|
+
uint32 indexed destination,
|
|
2535
|
+
bytes32 sender,
|
|
2536
|
+
string message
|
|
2537
|
+
);
|
|
2538
|
+
|
|
2539
|
+
constructor(address _mailbox, address _interchainGasPaymaster) initializer {
|
|
2540
|
+
__HyperlaneConnectionClient_initialize(
|
|
2541
|
+
_mailbox,
|
|
2542
|
+
_interchainGasPaymaster
|
|
2543
|
+
);
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
// ============ External functions ============
|
|
2547
|
+
|
|
2548
|
+
/**
|
|
2549
|
+
* @notice Sends a message to the _destinationDomain. Any msg.value is
|
|
2550
|
+
* used as interchain gas payment.
|
|
2551
|
+
* @param _destinationDomain The destination domain to send the message to.
|
|
2552
|
+
*/
|
|
2553
|
+
function sendHelloWorld(uint32 _destinationDomain, string calldata _message)
|
|
2554
|
+
external
|
|
2555
|
+
payable
|
|
2556
|
+
{
|
|
2557
|
+
sent += 1;
|
|
2558
|
+
sentTo[_destinationDomain] += 1;
|
|
2559
|
+
// TODO: pay for gas in v2
|
|
2560
|
+
_dispatch(_destinationDomain, bytes(_message));
|
|
2561
|
+
emit SentHelloWorld(
|
|
2562
|
+
mailbox.localDomain(),
|
|
2563
|
+
_destinationDomain,
|
|
2564
|
+
_message
|
|
2565
|
+
);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
// ============ Internal functions ============
|
|
2569
|
+
|
|
2570
|
+
/**
|
|
2571
|
+
* @notice Handles a message from a remote router.
|
|
2572
|
+
* @dev Only called for messages sent from a remote router, as enforced by Router.sol.
|
|
2573
|
+
* @param _origin The domain of the origin of the message.
|
|
2574
|
+
* @param _sender The sender of the message.
|
|
2575
|
+
* @param _message The message body.
|
|
2576
|
+
*/
|
|
2577
|
+
function _handle(
|
|
2578
|
+
uint32 _origin,
|
|
2579
|
+
bytes32 _sender,
|
|
2580
|
+
bytes calldata _message
|
|
2581
|
+
) internal override {
|
|
2582
|
+
received += 1;
|
|
2583
|
+
receivedFrom[_origin] += 1;
|
|
2584
|
+
emit ReceivedHelloWorld(
|
|
2585
|
+
_origin,
|
|
2586
|
+
mailbox.localDomain(),
|
|
2587
|
+
_sender,
|
|
2588
|
+
string(_message)
|
|
2589
|
+
);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
// File contracts/flattened.sol
|