@across-protocol/contracts 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +661 -0
- package/README.md +53 -0
- package/artifacts/@eth-optimism/contracts/L2/messaging/IL2ERC20Bridge.sol/IL2ERC20Bridge.dbg.json +4 -0
- package/artifacts/@eth-optimism/contracts/L2/messaging/IL2ERC20Bridge.sol/IL2ERC20Bridge.json +252 -0
- package/artifacts/@eth-optimism/contracts/libraries/bridge/CrossDomainEnabled.sol/CrossDomainEnabled.dbg.json +4 -0
- package/artifacts/@eth-optimism/contracts/libraries/bridge/CrossDomainEnabled.sol/CrossDomainEnabled.json +35 -0
- package/artifacts/@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol/ICrossDomainMessenger.dbg.json +4 -0
- package/artifacts/@eth-optimism/contracts/libraries/bridge/ICrossDomainMessenger.sol/ICrossDomainMessenger.json +110 -0
- package/artifacts/@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol/Lib_PredeployAddresses.dbg.json +4 -0
- package/artifacts/@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol/Lib_PredeployAddresses.json +10 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/AccessControl.json +215 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/IAccessControl.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/AccessControl.sol/IAccessControl.json +108 -0
- package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/access/Ownable.sol/Ownable.json +63 -0
- package/artifacts/@openzeppelin/contracts/security/Pausable.sol/Pausable.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/security/Pausable.sol/Pausable.json +50 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json +297 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/IERC20.sol/IERC20.json +194 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol/IERC20Metadata.json +233 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol/SafeERC20.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Address.sol/Address.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Context.sol/Context.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/Strings.sol/Strings.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/ERC165.sol/ERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/introspection/IERC165.sol/IERC165.json +30 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SafeMath.sol/SafeMath.json +10 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedSafeMath.sol/SignedSafeMath.dbg.json +4 -0
- package/artifacts/@openzeppelin/contracts/utils/math/SignedSafeMath.sol/SignedSafeMath.json +10 -0
- package/artifacts/@uma/core/contracts/common/implementation/Lockable.sol/Lockable.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/common/implementation/Lockable.sol/Lockable.json +16 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/Arbitrum_ParentMessenger.sol/Arbitrum_ParentMessenger.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/Arbitrum_ParentMessenger.sol/Arbitrum_ParentMessenger.json +611 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/ParentMessengerBase.sol/ParentMessengerBase.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/chain-adapters/ParentMessengerBase.sol/ParentMessengerBase.json +297 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerConsumerInterface.sol/ParentMessengerConsumerInterface.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerConsumerInterface.sol/ParentMessengerConsumerInterface.json +29 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerInterface.sol/ParentMessengerInterface.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/cross-chain-oracle/interfaces/ParentMessengerInterface.sol/ParentMessengerInterface.json +37 -0
- package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.json +24 -0
- package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.json +78 -0
- package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.json +24 -0
- package/artifacts/@uma/core/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.dbg.json +4 -0
- package/artifacts/@uma/core/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.json +24 -0
- package/artifacts/build-info/1cd64db7a8ac0a153df93d26826ad4e9.json +1653 -0
- package/artifacts/build-info/1f738b56edd7602183f2f8d2f23f6e90.json +1592 -0
- package/artifacts/build-info/343b9221be36acd9ddaca3f3b83d2e75.json +3943 -0
- package/artifacts/build-info/622e561692c193f4cd0ff989b5a231e2.json +5661 -0
- package/artifacts/build-info/8e408b49e0ff2873bc28d45221a7ff71.json +277715 -0
- package/artifacts/build-info/9d1a3182633612bd337d811d567d5d60.json +2072 -0
- package/artifacts/build-info/a8cd9c443d245fe513d6650634b60f93.json +23776 -0
- package/artifacts/build-info/d302d9d63fbafb5c8d635cc62cb1cc7c.json +167529 -0
- package/artifacts/contracts/common/implementation/AncillaryData.sol/AncillaryData.dbg.json +4 -0
- package/artifacts/contracts/common/implementation/AncillaryData.sol/AncillaryData.json +10 -0
- package/artifacts/contracts/common/implementation/FixedPoint.sol/FixedPoint.dbg.json +4 -0
- package/artifacts/contracts/common/implementation/FixedPoint.sol/FixedPoint.json +10 -0
- package/artifacts/contracts/common/implementation/Lockable.sol/Lockable.dbg.json +4 -0
- package/artifacts/contracts/common/implementation/Lockable.sol/Lockable.json +16 -0
- package/artifacts/contracts/common/implementation/MultiCaller.sol/MultiCaller.dbg.json +4 -0
- package/artifacts/contracts/common/implementation/MultiCaller.sol/MultiCaller.json +30 -0
- package/artifacts/contracts/common/implementation/Testable.sol/Testable.dbg.json +4 -0
- package/artifacts/contracts/common/implementation/Testable.sol/Testable.json +50 -0
- package/artifacts/contracts/common/implementation/Timer.sol/Timer.dbg.json +4 -0
- package/artifacts/contracts/common/implementation/Timer.sol/Timer.json +42 -0
- package/artifacts/contracts/common/interfaces/AddressWhitelistInterface.sol/AddressWhitelistInterface.dbg.json +4 -0
- package/artifacts/contracts/common/interfaces/AddressWhitelistInterface.sol/AddressWhitelistInterface.json +69 -0
- package/artifacts/contracts/external/avm/AVM_CrossDomainEnabled.sol/AVM_CrossDomainEnabled.dbg.json +4 -0
- package/artifacts/contracts/external/avm/AVM_CrossDomainEnabled.sol/AVM_CrossDomainEnabled.json +42 -0
- package/artifacts/contracts/external/avm/interfaces/ArbSys.sol/ArbSys.dbg.json +4 -0
- package/artifacts/contracts/external/avm/interfaces/ArbSys.sol/ArbSys.json +235 -0
- package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.dbg.json +4 -0
- package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/IBridge.json +24 -0
- package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.dbg.json +4 -0
- package/artifacts/contracts/external/avm/interfaces/iArbitrum_Inbox.sol/iArbitrum_Inbox.json +78 -0
- package/artifacts/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.dbg.json +4 -0
- package/artifacts/contracts/external/avm/interfaces/iArbitrum_Outbox.sol/iArbitrum_Outbox.json +24 -0
- package/artifacts/contracts/external/chainbridge/Bridge.sol/Bridge.dbg.json +4 -0
- package/artifacts/contracts/external/chainbridge/Bridge.sol/Bridge.json +1019 -0
- package/artifacts/contracts/external/chainbridge/handlers/GenericHandler.sol/GenericHandler.dbg.json +4 -0
- package/artifacts/contracts/external/chainbridge/handlers/GenericHandler.sol/GenericHandler.json +314 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IBridge.sol/IBridge.dbg.json +4 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IBridge.sol/IBridge.json +47 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IDepositExecute.sol/IDepositExecute.dbg.json +4 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IDepositExecute.sol/IDepositExecute.json +62 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IERCHandler.sol/IERCHandler.dbg.json +4 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IERCHandler.sol/IERCHandler.json +65 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IGenericHandler.sol/IGenericHandler.dbg.json +4 -0
- package/artifacts/contracts/external/chainbridge/interfaces/IGenericHandler.sol/IGenericHandler.json +39 -0
- package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.dbg.json +4 -0
- package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.json +35 -0
- package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/iOVM_CrossDomainMessenger.dbg.json +4 -0
- package/artifacts/contracts/external/ovm/OVM_CrossDomainEnabled.sol/iOVM_CrossDomainMessenger.json +86 -0
- package/artifacts/contracts/external/polygon/lib/Merkle.sol/Merkle.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/lib/Merkle.sol/Merkle.json +10 -0
- package/artifacts/contracts/external/polygon/lib/MerklePatriciaProof.sol/MerklePatriciaProof.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/lib/MerklePatriciaProof.sol/MerklePatriciaProof.json +10 -0
- package/artifacts/contracts/external/polygon/lib/RLPReader.sol/RLPReader.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/lib/RLPReader.sol/RLPReader.json +10 -0
- package/artifacts/contracts/external/polygon/test/FxChildMock.sol/FxChildMock.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/FxChildMock.sol/FxChildMock.json +104 -0
- package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IFxMessageProcessor.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IFxMessageProcessor.json +34 -0
- package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IStateReceiver.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/FxChildMock.sol/IStateReceiver.json +29 -0
- package/artifacts/contracts/external/polygon/test/FxRootMock.sol/FxRootMock.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/FxRootMock.sol/FxRootMock.json +79 -0
- package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IFxStateSender.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IFxStateSender.json +29 -0
- package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IStateSender.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/FxRootMock.sol/IStateSender.json +29 -0
- package/artifacts/contracts/external/polygon/test/StateSyncMock.sol/StateSyncMock.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/test/StateSyncMock.sol/StateSyncMock.json +54 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/FxBaseChildTunnel.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/FxBaseChildTunnel.json +86 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/IFxMessageProcessor.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol/IFxMessageProcessor.json +34 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/FxBaseRootTunnel.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/FxBaseRootTunnel.json +108 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/ICheckpointManager.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/ICheckpointManager.json +50 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/IFxStateSender.dbg.json +4 -0
- package/artifacts/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol/IFxStateSender.json +29 -0
- package/artifacts/contracts/insured-bridge/BridgeAdmin.sol/BridgeAdmin.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgeAdmin.sol/BridgeAdmin.json +662 -0
- package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/BridgeDepositBox.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/BridgeDepositBox.json +391 -0
- package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/TokenLike.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/TokenLike.json +30 -0
- package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/WETH9Like.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgeDepositBox.sol/WETH9Like.json +31 -0
- package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePool.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePool.json +1709 -0
- package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePoolProd.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgePool.sol/BridgePoolProd.json +1709 -0
- package/artifacts/contracts/insured-bridge/BridgePool.sol/WETH9Like.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/BridgePool.sol/WETH9Like.json +31 -0
- package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/AVM_BridgeDepositBox.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/AVM_BridgeDepositBox.json +564 -0
- package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/StandardBridgeLike.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol/StandardBridgeLike.json +45 -0
- package/artifacts/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol/Arbitrum_CrossDomainEnabled.json +24 -0
- package/artifacts/contracts/insured-bridge/avm/Arbitrum_Messenger.sol/Arbitrum_Messenger.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/avm/Arbitrum_Messenger.sol/Arbitrum_Messenger.json +191 -0
- package/artifacts/contracts/insured-bridge/interfaces/BridgeAdminInterface.sol/BridgeAdminInterface.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/interfaces/BridgeAdminInterface.sol/BridgeAdminInterface.json +319 -0
- package/artifacts/contracts/insured-bridge/interfaces/BridgePoolInterface.sol/BridgePoolInterface.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/interfaces/BridgePoolInterface.sol/BridgePoolInterface.json +63 -0
- package/artifacts/contracts/insured-bridge/interfaces/MessengerInterface.sol/MessengerInterface.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/interfaces/MessengerInterface.sol/MessengerInterface.json +54 -0
- package/artifacts/contracts/insured-bridge/ovm/OVM_BridgeDepositBox.sol/OVM_BridgeDepositBox.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/OVM_BridgeDepositBox.sol/OVM_BridgeDepositBox.json +528 -0
- package/artifacts/contracts/insured-bridge/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/OVM_CrossDomainEnabled.sol/OVM_CrossDomainEnabled.json +35 -0
- package/artifacts/contracts/insured-bridge/ovm/OVM_OETH_BridgeDepositBox.sol/OVM_OETH_BridgeDepositBox.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/OVM_OETH_BridgeDepositBox.sol/OVM_OETH_BridgeDepositBox.json +572 -0
- package/artifacts/contracts/insured-bridge/ovm/Optimism_Messenger.sol/Optimism_Messenger.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/Optimism_Messenger.sol/Optimism_Messenger.json +130 -0
- package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/Optimism_Wrapper.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/Optimism_Wrapper.json +142 -0
- package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/WETH9Like.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/Optimism_Wrapper.sol/WETH9Like.json +55 -0
- package/artifacts/contracts/insured-bridge/ovm/iOVM_CrossDomainMessenger.sol/iOVM_CrossDomainMessenger.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/ovm/iOVM_CrossDomainMessenger.sol/iOVM_CrossDomainMessenger.json +86 -0
- package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_BridgeMock.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_BridgeMock.json +68 -0
- package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_InboxMock.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_InboxMock.json +78 -0
- package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_OutboxMock.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/test/Arbitrum_InboxMock.sol/Arbitrum_OutboxMock.json +24 -0
- package/artifacts/contracts/insured-bridge/test/BridgeDepositBoxMock.sol/BridgeDepositBoxMock.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/test/BridgeDepositBoxMock.sol/BridgeDepositBoxMock.json +510 -0
- package/artifacts/contracts/insured-bridge/test/MessengerMock.sol/MessengerMock.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/test/MessengerMock.sol/MessengerMock.json +85 -0
- package/artifacts/contracts/insured-bridge/test/OVM_L1CrossDomainMessengerMock.sol/OVM_L1CrossDomainMessengerMock.dbg.json +4 -0
- package/artifacts/contracts/insured-bridge/test/OVM_L1CrossDomainMessengerMock.sol/OVM_L1CrossDomainMessengerMock.json +110 -0
- package/artifacts/contracts/oracle/implementation/Constants.sol/OptimisticOracleConstraints.dbg.json +4 -0
- package/artifacts/contracts/oracle/implementation/Constants.sol/OptimisticOracleConstraints.json +24 -0
- package/artifacts/contracts/oracle/implementation/Constants.sol/OracleInterfaces.dbg.json +4 -0
- package/artifacts/contracts/oracle/implementation/Constants.sol/OracleInterfaces.json +141 -0
- package/artifacts/contracts/oracle/interfaces/FinderInterface.sol/FinderInterface.dbg.json +4 -0
- package/artifacts/contracts/oracle/interfaces/FinderInterface.sol/FinderInterface.json +48 -0
- package/artifacts/contracts/oracle/interfaces/IdentifierWhitelistInterface.sol/IdentifierWhitelistInterface.dbg.json +4 -0
- package/artifacts/contracts/oracle/interfaces/IdentifierWhitelistInterface.sol/IdentifierWhitelistInterface.json +56 -0
- package/artifacts/contracts/oracle/interfaces/OptimisticOracleInterface.sol/OptimisticOracleInterface.dbg.json +4 -0
- package/artifacts/contracts/oracle/interfaces/OptimisticOracleInterface.sol/OptimisticOracleInterface.json +555 -0
- package/artifacts/contracts/oracle/interfaces/SkinnyOptimisticOracleInterface.sol/SkinnyOptimisticOracleInterface.dbg.json +4 -0
- package/artifacts/contracts/oracle/interfaces/SkinnyOptimisticOracleInterface.sol/SkinnyOptimisticOracleInterface.json +853 -0
- package/artifacts/contracts/oracle/interfaces/StoreInterface.sol/StoreInterface.dbg.json +4 -0
- package/artifacts/contracts/oracle/interfaces/StoreInterface.sol/StoreInterface.json +124 -0
- package/contracts/common/implementation/AncillaryData.sol +144 -0
- package/contracts/common/implementation/FixedPoint.sol +763 -0
- package/contracts/common/implementation/Lockable.sol +61 -0
- package/contracts/common/implementation/MultiCaller.sol +27 -0
- package/contracts/common/implementation/Testable.sol +52 -0
- package/contracts/common/implementation/Timer.sol +30 -0
- package/contracts/common/interfaces/AddressWhitelistInterface.sol +12 -0
- package/contracts/external/avm/AVM_CrossDomainEnabled.sol +43 -0
- package/contracts/external/avm/interfaces/ArbSys.sol +79 -0
- package/contracts/external/avm/interfaces/iArbitrum_Inbox.sol +28 -0
- package/contracts/external/avm/interfaces/iArbitrum_Outbox.sol +26 -0
- package/contracts/external/chainbridge/Bridge.sol +454 -0
- package/contracts/external/chainbridge/handlers/GenericHandler.sol +237 -0
- package/contracts/external/chainbridge/interfaces/IBridge.sol +20 -0
- package/contracts/external/chainbridge/interfaces/IDepositExecute.sol +29 -0
- package/contracts/external/chainbridge/interfaces/IERCHandler.sol +33 -0
- package/contracts/external/chainbridge/interfaces/IGenericHandler.sol +23 -0
- package/contracts/external/ovm/OVM_CrossDomainEnabled.sol +114 -0
- package/contracts/external/polygon/lib/Merkle.sol +36 -0
- package/contracts/external/polygon/lib/MerklePatriciaProof.sol +139 -0
- package/contracts/external/polygon/lib/RLPReader.sol +251 -0
- package/contracts/external/polygon/test/FxChildMock.sol +42 -0
- package/contracts/external/polygon/test/FxRootMock.sol +32 -0
- package/contracts/external/polygon/test/StateSyncMock.sol +26 -0
- package/contracts/external/polygon/tunnel/FxBaseChildTunnel.sol +80 -0
- package/contracts/external/polygon/tunnel/FxBaseRootTunnel.sol +185 -0
- package/contracts/insured-bridge/BridgeAdmin.sol +394 -0
- package/contracts/insured-bridge/BridgeDepositBox.sol +245 -0
- package/contracts/insured-bridge/BridgePool.sol +980 -0
- package/contracts/insured-bridge/avm/AVM_BridgeDepositBox.sol +144 -0
- package/contracts/insured-bridge/avm/Arbitrum_CrossDomainEnabled.sol +67 -0
- package/contracts/insured-bridge/avm/Arbitrum_Messenger.sol +72 -0
- package/contracts/insured-bridge/interfaces/BridgeAdminInterface.sol +44 -0
- package/contracts/insured-bridge/interfaces/BridgePoolInterface.sol +14 -0
- package/contracts/insured-bridge/interfaces/MessengerInterface.sol +18 -0
- package/contracts/insured-bridge/ovm/OVM_BridgeDepositBox.sol +135 -0
- package/contracts/insured-bridge/ovm/OVM_CrossDomainEnabled.sol +84 -0
- package/contracts/insured-bridge/ovm/OVM_OETH_BridgeDepositBox.sol +89 -0
- package/contracts/insured-bridge/ovm/Optimism_Messenger.sol +34 -0
- package/contracts/insured-bridge/ovm/Optimism_Wrapper.sol +59 -0
- package/contracts/insured-bridge/ovm/iOVM_CrossDomainMessenger.sol +41 -0
- package/contracts/insured-bridge/test/Arbitrum_InboxMock.sol +50 -0
- package/contracts/insured-bridge/test/BridgeDepositBoxMock.sol +113 -0
- package/contracts/insured-bridge/test/MessengerMock.sol +32 -0
- package/contracts/insured-bridge/test/OVM_L1CrossDomainMessengerMock.sol +16 -0
- package/contracts/oracle/implementation/Constants.sol +29 -0
- package/contracts/oracle/interfaces/FinderInterface.sol +22 -0
- package/contracts/oracle/interfaces/IdentifierWhitelistInterface.sol +28 -0
- package/contracts/oracle/interfaces/OptimisticOracleInterface.sol +263 -0
- package/contracts/oracle/interfaces/SkinnyOptimisticOracleInterface.sol +251 -0
- package/contracts/oracle/interfaces/StoreInterface.sol +46 -0
- package/package.json +60 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
@title Interface for Bridge contract.
|
|
6
|
+
@author ChainSafe Systems.
|
|
7
|
+
*/
|
|
8
|
+
interface IBridge {
|
|
9
|
+
/**
|
|
10
|
+
@notice Exposing getter for {_chainID} instead of forcing the use of call.
|
|
11
|
+
@return uint8 The {_chainID} that is currently set for the Bridge contract.
|
|
12
|
+
*/
|
|
13
|
+
function _chainID() external returns (uint8);
|
|
14
|
+
|
|
15
|
+
function deposit(
|
|
16
|
+
uint8 destinationChainID,
|
|
17
|
+
bytes32 resourceID,
|
|
18
|
+
bytes calldata data
|
|
19
|
+
) external;
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
@title Interface for handler contracts that support deposits and deposit executions.
|
|
6
|
+
@author ChainSafe Systems.
|
|
7
|
+
*/
|
|
8
|
+
interface IDepositExecute {
|
|
9
|
+
/**
|
|
10
|
+
@notice It is intended that deposit are made using the Bridge contract.
|
|
11
|
+
@param destinationChainID Chain ID deposit is expected to be bridged to.
|
|
12
|
+
@param depositNonce This value is generated as an ID by the Bridge contract.
|
|
13
|
+
@param depositer Address of account making the deposit in the Bridge contract.
|
|
14
|
+
@param data Consists of additional data needed for a specific deposit.
|
|
15
|
+
*/
|
|
16
|
+
function deposit(
|
|
17
|
+
bytes32 resourceID,
|
|
18
|
+
uint8 destinationChainID,
|
|
19
|
+
uint64 depositNonce,
|
|
20
|
+
address depositer,
|
|
21
|
+
bytes calldata data
|
|
22
|
+
) external;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
@notice It is intended that proposals are executed by the Bridge contract.
|
|
26
|
+
@param data Consists of additional data needed for a specific deposit execution.
|
|
27
|
+
*/
|
|
28
|
+
function executeProposal(bytes32 resourceID, bytes calldata data) external;
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
@title Interface to be used with handlers that support ERC20s and ERC721s.
|
|
6
|
+
@author ChainSafe Systems.
|
|
7
|
+
*/
|
|
8
|
+
interface IERCHandler {
|
|
9
|
+
/**
|
|
10
|
+
@notice Correlates {resourceID} with {contractAddress}.
|
|
11
|
+
@param resourceID ResourceID to be used when making deposits.
|
|
12
|
+
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
|
|
13
|
+
*/
|
|
14
|
+
function setResource(bytes32 resourceID, address contractAddress) external;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
@notice Marks {contractAddress} as mintable/burnable.
|
|
18
|
+
@param contractAddress Address of contract to be used when making or executing deposits.
|
|
19
|
+
*/
|
|
20
|
+
function setBurnable(address contractAddress) external;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
@notice Used to manually release funds from ERC safes.
|
|
24
|
+
@param tokenAddress Address of token contract to release.
|
|
25
|
+
@param recipient Address to release tokens to.
|
|
26
|
+
@param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to release.
|
|
27
|
+
*/
|
|
28
|
+
function withdraw(
|
|
29
|
+
address tokenAddress,
|
|
30
|
+
address recipient,
|
|
31
|
+
uint256 amountOrTokenID
|
|
32
|
+
) external;
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
@title Interface for handler that handles generic deposits and deposit executions.
|
|
6
|
+
@dev Copied directly from here: https://github.com/ChainSafe/chainbridge-solidity/releases/tag/v1.0.0.
|
|
7
|
+
@author ChainSafe Systems.
|
|
8
|
+
*/
|
|
9
|
+
interface IGenericHandler {
|
|
10
|
+
/**
|
|
11
|
+
@notice Correlates {resourceID} with {contractAddress}, {depositFunctionSig}, and {executeFunctionSig}.
|
|
12
|
+
@param resourceID ResourceID to be used when making deposits.
|
|
13
|
+
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
|
|
14
|
+
@param depositFunctionSig Function signature of method to be called in {contractAddress} when a deposit is made.
|
|
15
|
+
@param executeFunctionSig Function signature of method to be called in {contractAddress} when a deposit is executed.
|
|
16
|
+
*/
|
|
17
|
+
function setResource(
|
|
18
|
+
bytes32 resourceID,
|
|
19
|
+
address contractAddress,
|
|
20
|
+
bytes4 depositFunctionSig,
|
|
21
|
+
bytes4 executeFunctionSig
|
|
22
|
+
) external;
|
|
23
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copied from: https://github.com/ethereum-optimism/optimism/blob/5fc728da7381eda6b6f858c091636c947186a3ce/packages/contracts/contracts/optimistic-ethereum/libraries/bridge/OVM_CrossDomainEnabled.sol
|
|
2
|
+
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title iOVM_CrossDomainMessenger
|
|
8
|
+
*/
|
|
9
|
+
interface iOVM_CrossDomainMessenger {
|
|
10
|
+
/**********
|
|
11
|
+
* Events *
|
|
12
|
+
**********/
|
|
13
|
+
|
|
14
|
+
event SentMessage(bytes message);
|
|
15
|
+
event RelayedMessage(bytes32 msgHash);
|
|
16
|
+
event FailedRelayedMessage(bytes32 msgHash);
|
|
17
|
+
|
|
18
|
+
/*************
|
|
19
|
+
* Variables *
|
|
20
|
+
*************/
|
|
21
|
+
|
|
22
|
+
function xDomainMessageSender() external view returns (address);
|
|
23
|
+
|
|
24
|
+
/********************
|
|
25
|
+
* Public Functions *
|
|
26
|
+
********************/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Sends a cross domain message to the target messenger.
|
|
30
|
+
* @param _target Target contract address.
|
|
31
|
+
* @param _message Message to send to the target.
|
|
32
|
+
* @param _gasLimit Gas limit for the provided message.
|
|
33
|
+
*/
|
|
34
|
+
function sendMessage(
|
|
35
|
+
address _target,
|
|
36
|
+
bytes calldata _message,
|
|
37
|
+
uint32 _gasLimit
|
|
38
|
+
) external;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @title OVM_CrossDomainEnabled
|
|
43
|
+
* @dev Helper contract for contracts performing cross-domain communications
|
|
44
|
+
*
|
|
45
|
+
* Compiler used: defined by inheriting contract
|
|
46
|
+
* Runtime target: defined by inheriting contract
|
|
47
|
+
*/
|
|
48
|
+
contract OVM_CrossDomainEnabled {
|
|
49
|
+
/*************
|
|
50
|
+
* Variables *
|
|
51
|
+
*************/
|
|
52
|
+
|
|
53
|
+
// Messenger contract used to send and recieve messages from the other domain.
|
|
54
|
+
address public messenger;
|
|
55
|
+
|
|
56
|
+
/***************
|
|
57
|
+
* Constructor *
|
|
58
|
+
***************/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param _messenger Address of the CrossDomainMessenger on the current layer.
|
|
62
|
+
*/
|
|
63
|
+
constructor(address _messenger) {
|
|
64
|
+
messenger = _messenger;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**********************
|
|
68
|
+
* Function Modifiers *
|
|
69
|
+
**********************/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Enforces that the modified function is only callable by a specific cross-domain account.
|
|
73
|
+
* @param _sourceDomainAccount The only account on the originating domain which is
|
|
74
|
+
* authenticated to call this function.
|
|
75
|
+
*/
|
|
76
|
+
modifier onlyFromCrossDomainAccount(address _sourceDomainAccount) {
|
|
77
|
+
require(msg.sender == address(getCrossDomainMessenger()), "OVM_XCHAIN: messenger contract unauthenticated");
|
|
78
|
+
|
|
79
|
+
require(
|
|
80
|
+
getCrossDomainMessenger().xDomainMessageSender() == _sourceDomainAccount,
|
|
81
|
+
"OVM_XCHAIN: wrong sender of cross-domain message"
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
_;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**********************
|
|
88
|
+
* Internal Functions *
|
|
89
|
+
**********************/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Gets the messenger, usually from storage. This function is exposed in case a child contract
|
|
93
|
+
* needs to override.
|
|
94
|
+
* @return The address of the cross-domain messenger contract which should be used.
|
|
95
|
+
*/
|
|
96
|
+
function getCrossDomainMessenger() internal virtual returns (iOVM_CrossDomainMessenger) {
|
|
97
|
+
return iOVM_CrossDomainMessenger(messenger);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Sends a message to an account on another domain
|
|
102
|
+
* @param _crossDomainTarget The intended recipient on the destination domain
|
|
103
|
+
* @param _message The data to send to the target (usually calldata to a function with
|
|
104
|
+
* `onlyFromCrossDomainAccount()`)
|
|
105
|
+
* @param _gasLimit The gasLimit for the receipt of the message on the target domain.
|
|
106
|
+
*/
|
|
107
|
+
function sendCrossDomainMessage(
|
|
108
|
+
address _crossDomainTarget,
|
|
109
|
+
uint32 _gasLimit,
|
|
110
|
+
bytes memory _message
|
|
111
|
+
) internal {
|
|
112
|
+
getCrossDomainMessenger().sendMessage(_crossDomainTarget, _message, _gasLimit);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copied with no modifications from Polygon demo FxTunnel repo: https://github.com/jdkanani/fx-portal
|
|
3
|
+
// except bumping version from 0.7.3 --> 0.8
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
library Merkle {
|
|
7
|
+
function checkMembership(
|
|
8
|
+
bytes32 leaf,
|
|
9
|
+
uint256 index,
|
|
10
|
+
bytes32 rootHash,
|
|
11
|
+
bytes memory proof
|
|
12
|
+
) internal pure returns (bool) {
|
|
13
|
+
require(proof.length % 32 == 0, "Invalid proof length");
|
|
14
|
+
uint256 proofHeight = proof.length / 32;
|
|
15
|
+
// Proof of size n means, height of the tree is n+1.
|
|
16
|
+
// In a tree of height n+1, max #leafs possible is 2 ^ n
|
|
17
|
+
require(index < 2**proofHeight, "Leaf index is too big");
|
|
18
|
+
|
|
19
|
+
bytes32 proofElement;
|
|
20
|
+
bytes32 computedHash = leaf;
|
|
21
|
+
for (uint256 i = 32; i <= proof.length; i += 32) {
|
|
22
|
+
assembly {
|
|
23
|
+
proofElement := mload(add(proof, i))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (index % 2 == 0) {
|
|
27
|
+
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
|
|
28
|
+
} else {
|
|
29
|
+
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
index = index / 2;
|
|
33
|
+
}
|
|
34
|
+
return computedHash == rootHash;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copied with no modifications from Polygon demo FxTunnel repo: https://github.com/jdkanani/fx-portal
|
|
3
|
+
// except bumping version from 0.7.3 --> 0.8
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
import { RLPReader } from "./RLPReader.sol";
|
|
7
|
+
|
|
8
|
+
library MerklePatriciaProof {
|
|
9
|
+
/*
|
|
10
|
+
* @dev Verifies a merkle patricia proof.
|
|
11
|
+
* @param value The terminating value in the trie.
|
|
12
|
+
* @param encodedPath The path in the trie leading to value.
|
|
13
|
+
* @param rlpParentNodes The rlp encoded stack of nodes.
|
|
14
|
+
* @param root The root hash of the trie.
|
|
15
|
+
* @return The boolean validity of the proof.
|
|
16
|
+
*/
|
|
17
|
+
function verify(
|
|
18
|
+
bytes memory value,
|
|
19
|
+
bytes memory encodedPath,
|
|
20
|
+
bytes memory rlpParentNodes,
|
|
21
|
+
bytes32 root
|
|
22
|
+
) internal pure returns (bool proofValidity) {
|
|
23
|
+
RLPReader.RLPItem memory item = RLPReader.toRlpItem(rlpParentNodes);
|
|
24
|
+
RLPReader.RLPItem[] memory parentNodes = RLPReader.toList(item);
|
|
25
|
+
|
|
26
|
+
bytes memory currentNode;
|
|
27
|
+
RLPReader.RLPItem[] memory currentNodeList;
|
|
28
|
+
|
|
29
|
+
bytes32 nodeKey = root;
|
|
30
|
+
uint256 pathPtr = 0;
|
|
31
|
+
|
|
32
|
+
bytes memory path = _getNibbleArray(encodedPath);
|
|
33
|
+
if (path.length == 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (uint256 i = 0; i < parentNodes.length; i++) {
|
|
38
|
+
if (pathPtr > path.length) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
currentNode = RLPReader.toRlpBytes(parentNodes[i]);
|
|
43
|
+
if (nodeKey != keccak256(currentNode)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
currentNodeList = RLPReader.toList(parentNodes[i]);
|
|
47
|
+
|
|
48
|
+
if (currentNodeList.length == 17) {
|
|
49
|
+
if (pathPtr == path.length) {
|
|
50
|
+
if (keccak256(RLPReader.toBytes(currentNodeList[16])) == keccak256(value)) {
|
|
51
|
+
return true;
|
|
52
|
+
} else {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
uint8 nextPathNibble = uint8(path[pathPtr]);
|
|
58
|
+
if (nextPathNibble > 16) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
nodeKey = bytes32(RLPReader.toUintStrict(currentNodeList[nextPathNibble]));
|
|
62
|
+
pathPtr += 1;
|
|
63
|
+
} else if (currentNodeList.length == 2) {
|
|
64
|
+
uint256 traversed = _nibblesToTraverse(RLPReader.toBytes(currentNodeList[0]), path, pathPtr);
|
|
65
|
+
if (pathPtr + traversed == path.length) {
|
|
66
|
+
//leaf node
|
|
67
|
+
if (keccak256(RLPReader.toBytes(currentNodeList[1])) == keccak256(value)) {
|
|
68
|
+
return true;
|
|
69
|
+
} else {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//extension node
|
|
75
|
+
if (traversed == 0) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
pathPtr += traversed;
|
|
80
|
+
nodeKey = bytes32(RLPReader.toUintStrict(currentNodeList[1]));
|
|
81
|
+
} else {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _nibblesToTraverse(
|
|
88
|
+
bytes memory encodedPartialPath,
|
|
89
|
+
bytes memory path,
|
|
90
|
+
uint256 pathPtr
|
|
91
|
+
) private pure returns (uint256) {
|
|
92
|
+
uint256 len = 0;
|
|
93
|
+
// encodedPartialPath has elements that are each two hex characters (1 byte), but partialPath
|
|
94
|
+
// and slicedPath have elements that are each one hex character (1 nibble)
|
|
95
|
+
bytes memory partialPath = _getNibbleArray(encodedPartialPath);
|
|
96
|
+
bytes memory slicedPath = new bytes(partialPath.length);
|
|
97
|
+
|
|
98
|
+
// pathPtr counts nibbles in path
|
|
99
|
+
// partialPath.length is a number of nibbles
|
|
100
|
+
for (uint256 i = pathPtr; i < pathPtr + partialPath.length; i++) {
|
|
101
|
+
bytes1 pathNibble = path[i];
|
|
102
|
+
slicedPath[i - pathPtr] = pathNibble;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (keccak256(partialPath) == keccak256(slicedPath)) {
|
|
106
|
+
len = partialPath.length;
|
|
107
|
+
} else {
|
|
108
|
+
len = 0;
|
|
109
|
+
}
|
|
110
|
+
return len;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// bytes b must be hp encoded
|
|
114
|
+
function _getNibbleArray(bytes memory b) internal pure returns (bytes memory) {
|
|
115
|
+
bytes memory nibbles = "";
|
|
116
|
+
if (b.length > 0) {
|
|
117
|
+
uint8 offset;
|
|
118
|
+
uint8 hpNibble = uint8(_getNthNibbleOfBytes(0, b));
|
|
119
|
+
if (hpNibble == 1 || hpNibble == 3) {
|
|
120
|
+
nibbles = new bytes(b.length * 2 - 1);
|
|
121
|
+
bytes1 oddNibble = _getNthNibbleOfBytes(1, b);
|
|
122
|
+
nibbles[0] = oddNibble;
|
|
123
|
+
offset = 1;
|
|
124
|
+
} else {
|
|
125
|
+
nibbles = new bytes(b.length * 2 - 2);
|
|
126
|
+
offset = 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
for (uint256 i = offset; i < nibbles.length; i++) {
|
|
130
|
+
nibbles[i] = _getNthNibbleOfBytes(i - offset + 2, b);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return nibbles;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _getNthNibbleOfBytes(uint256 n, bytes memory str) private pure returns (bytes1) {
|
|
137
|
+
return bytes1(n % 2 == 0 ? uint8(str[n / 2]) / 0x10 : uint8(str[n / 2]) % 0x10);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copied mostly from Polygon demo FxTunnel repo: https://github.com/jdkanani/fx-portal.
|
|
3
|
+
// There are two modifications such that this contract compiles with Solidity v8:
|
|
4
|
+
// - Line 86: cannot convert directly from uint256 --> address
|
|
5
|
+
// - Line 226: cannot rely on wrapping arithmetic, must explicitly catch underflow/overflow with an unchecked{...}
|
|
6
|
+
// statement
|
|
7
|
+
// More details on Solidity v0.8.0 breaking changes here:
|
|
8
|
+
// https://docs.soliditylang.org/en/v0.8.4/080-breaking-changes.html#new-restrictions
|
|
9
|
+
pragma solidity ^0.8.0;
|
|
10
|
+
|
|
11
|
+
library RLPReader {
|
|
12
|
+
uint8 constant STRING_SHORT_START = 0x80;
|
|
13
|
+
uint8 constant STRING_LONG_START = 0xb8;
|
|
14
|
+
uint8 constant LIST_SHORT_START = 0xc0;
|
|
15
|
+
uint8 constant LIST_LONG_START = 0xf8;
|
|
16
|
+
uint8 constant WORD_SIZE = 32;
|
|
17
|
+
|
|
18
|
+
struct RLPItem {
|
|
19
|
+
uint256 len;
|
|
20
|
+
uint256 memPtr;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* @param item RLP encoded bytes
|
|
25
|
+
*/
|
|
26
|
+
function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) {
|
|
27
|
+
require(item.length > 0, "RLPReader: INVALID_BYTES_LENGTH");
|
|
28
|
+
uint256 memPtr;
|
|
29
|
+
assembly {
|
|
30
|
+
memPtr := add(item, 0x20)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return RLPItem(item.length, memPtr);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* @param item RLP encoded list in bytes
|
|
38
|
+
*/
|
|
39
|
+
function toList(RLPItem memory item) internal pure returns (RLPItem[] memory) {
|
|
40
|
+
require(isList(item), "RLPReader: ITEM_NOT_LIST");
|
|
41
|
+
|
|
42
|
+
uint256 items = numItems(item);
|
|
43
|
+
RLPItem[] memory result = new RLPItem[](items);
|
|
44
|
+
uint256 listLength = _itemLength(item.memPtr);
|
|
45
|
+
require(listLength == item.len, "RLPReader: LIST_DECODED_LENGTH_MISMATCH");
|
|
46
|
+
|
|
47
|
+
uint256 memPtr = item.memPtr + _payloadOffset(item.memPtr);
|
|
48
|
+
uint256 dataLen;
|
|
49
|
+
for (uint256 i = 0; i < items; i++) {
|
|
50
|
+
dataLen = _itemLength(memPtr);
|
|
51
|
+
result[i] = RLPItem(dataLen, memPtr);
|
|
52
|
+
memPtr = memPtr + dataLen;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// @return indicator whether encoded payload is a list. negate this function call for isData.
|
|
59
|
+
function isList(RLPItem memory item) internal pure returns (bool) {
|
|
60
|
+
uint8 byte0;
|
|
61
|
+
uint256 memPtr = item.memPtr;
|
|
62
|
+
assembly {
|
|
63
|
+
byte0 := byte(0, mload(memPtr))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (byte0 < LIST_SHORT_START) return false;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** RLPItem conversions into data types **/
|
|
71
|
+
|
|
72
|
+
// @returns raw rlp encoding in bytes
|
|
73
|
+
function toRlpBytes(RLPItem memory item) internal pure returns (bytes memory) {
|
|
74
|
+
bytes memory result = new bytes(item.len);
|
|
75
|
+
|
|
76
|
+
uint256 ptr;
|
|
77
|
+
assembly {
|
|
78
|
+
ptr := add(0x20, result)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
copy(item.memPtr, ptr, item.len);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function toAddress(RLPItem memory item) internal pure returns (address) {
|
|
86
|
+
require(!isList(item), "RLPReader: DECODING_LIST_AS_ADDRESS");
|
|
87
|
+
// 1 byte for the length prefix
|
|
88
|
+
require(item.len == 21, "RLPReader: INVALID_ADDRESS_LENGTH");
|
|
89
|
+
|
|
90
|
+
return address(uint160(toUint(item)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function toUint(RLPItem memory item) internal pure returns (uint256) {
|
|
94
|
+
require(!isList(item), "RLPReader: DECODING_LIST_AS_UINT");
|
|
95
|
+
require(item.len <= 33, "RLPReader: INVALID_UINT_LENGTH");
|
|
96
|
+
|
|
97
|
+
uint256 itemLength = _itemLength(item.memPtr);
|
|
98
|
+
require(itemLength == item.len, "RLPReader: UINT_DECODED_LENGTH_MISMATCH");
|
|
99
|
+
|
|
100
|
+
uint256 offset = _payloadOffset(item.memPtr);
|
|
101
|
+
uint256 len = item.len - offset;
|
|
102
|
+
uint256 result;
|
|
103
|
+
uint256 memPtr = item.memPtr + offset;
|
|
104
|
+
assembly {
|
|
105
|
+
result := mload(memPtr)
|
|
106
|
+
|
|
107
|
+
// shfit to the correct location if neccesary
|
|
108
|
+
if lt(len, 32) {
|
|
109
|
+
result := div(result, exp(256, sub(32, len)))
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// enforces 32 byte length
|
|
117
|
+
function toUintStrict(RLPItem memory item) internal pure returns (uint256) {
|
|
118
|
+
uint256 itemLength = _itemLength(item.memPtr);
|
|
119
|
+
require(itemLength == item.len, "RLPReader: UINT_STRICT_DECODED_LENGTH_MISMATCH");
|
|
120
|
+
// one byte prefix
|
|
121
|
+
require(item.len == 33, "RLPReader: INVALID_UINT_STRICT_LENGTH");
|
|
122
|
+
|
|
123
|
+
uint256 result;
|
|
124
|
+
uint256 memPtr = item.memPtr + 1;
|
|
125
|
+
assembly {
|
|
126
|
+
result := mload(memPtr)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function toBytes(RLPItem memory item) internal pure returns (bytes memory) {
|
|
133
|
+
uint256 listLength = _itemLength(item.memPtr);
|
|
134
|
+
require(listLength == item.len, "RLPReader: BYTES_DECODED_LENGTH_MISMATCH");
|
|
135
|
+
uint256 offset = _payloadOffset(item.memPtr);
|
|
136
|
+
|
|
137
|
+
uint256 len = item.len - offset; // data length
|
|
138
|
+
bytes memory result = new bytes(len);
|
|
139
|
+
|
|
140
|
+
uint256 destPtr;
|
|
141
|
+
assembly {
|
|
142
|
+
destPtr := add(0x20, result)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
copy(item.memPtr + offset, destPtr, len);
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* Private Helpers
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
// @return number of payload items inside an encoded list.
|
|
154
|
+
function numItems(RLPItem memory item) private pure returns (uint256) {
|
|
155
|
+
// add `isList` check if `item` is expected to be passsed without a check from calling function
|
|
156
|
+
// require(isList(item), "RLPReader: NUM_ITEMS_NOT_LIST");
|
|
157
|
+
|
|
158
|
+
uint256 count = 0;
|
|
159
|
+
uint256 currPtr = item.memPtr + _payloadOffset(item.memPtr);
|
|
160
|
+
uint256 endPtr = item.memPtr + item.len;
|
|
161
|
+
while (currPtr < endPtr) {
|
|
162
|
+
currPtr = currPtr + _itemLength(currPtr); // skip over an item
|
|
163
|
+
require(currPtr <= endPtr, "RLPReader: NUM_ITEMS_DECODED_LENGTH_MISMATCH");
|
|
164
|
+
count++;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return count;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// @return entire rlp item byte length
|
|
171
|
+
function _itemLength(uint256 memPtr) private pure returns (uint256) {
|
|
172
|
+
uint256 itemLen;
|
|
173
|
+
uint256 byte0;
|
|
174
|
+
assembly {
|
|
175
|
+
byte0 := byte(0, mload(memPtr))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (byte0 < STRING_SHORT_START) itemLen = 1;
|
|
179
|
+
else if (byte0 < STRING_LONG_START) itemLen = byte0 - STRING_SHORT_START + 1;
|
|
180
|
+
else if (byte0 < LIST_SHORT_START) {
|
|
181
|
+
assembly {
|
|
182
|
+
let byteLen := sub(byte0, 0xb7) // # of bytes the actual length is
|
|
183
|
+
memPtr := add(memPtr, 1) // skip over the first byte
|
|
184
|
+
|
|
185
|
+
/* 32 byte word size */
|
|
186
|
+
let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to get the len
|
|
187
|
+
itemLen := add(dataLen, add(byteLen, 1))
|
|
188
|
+
}
|
|
189
|
+
} else if (byte0 < LIST_LONG_START) {
|
|
190
|
+
itemLen = byte0 - LIST_SHORT_START + 1;
|
|
191
|
+
} else {
|
|
192
|
+
assembly {
|
|
193
|
+
let byteLen := sub(byte0, 0xf7)
|
|
194
|
+
memPtr := add(memPtr, 1)
|
|
195
|
+
|
|
196
|
+
let dataLen := div(mload(memPtr), exp(256, sub(32, byteLen))) // right shifting to the correct length
|
|
197
|
+
itemLen := add(dataLen, add(byteLen, 1))
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return itemLen;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// @return number of bytes until the data
|
|
205
|
+
function _payloadOffset(uint256 memPtr) private pure returns (uint256) {
|
|
206
|
+
uint256 byte0;
|
|
207
|
+
assembly {
|
|
208
|
+
byte0 := byte(0, mload(memPtr))
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (byte0 < STRING_SHORT_START) return 0;
|
|
212
|
+
else if (byte0 < STRING_LONG_START || (byte0 >= LIST_SHORT_START && byte0 < LIST_LONG_START)) return 1;
|
|
213
|
+
else if (byte0 < LIST_SHORT_START)
|
|
214
|
+
// being explicit
|
|
215
|
+
return byte0 - (STRING_LONG_START - 1) + 1;
|
|
216
|
+
else return byte0 - (LIST_LONG_START - 1) + 1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/*
|
|
220
|
+
* @param src Pointer to source
|
|
221
|
+
* @param dest Pointer to destination
|
|
222
|
+
* @param len Amount of memory to copy from the source
|
|
223
|
+
*/
|
|
224
|
+
function copy(
|
|
225
|
+
uint256 src,
|
|
226
|
+
uint256 dest,
|
|
227
|
+
uint256 len
|
|
228
|
+
) private pure {
|
|
229
|
+
if (len == 0) return;
|
|
230
|
+
|
|
231
|
+
// copy as many word sizes as possible
|
|
232
|
+
for (; len >= WORD_SIZE; len -= WORD_SIZE) {
|
|
233
|
+
assembly {
|
|
234
|
+
mstore(dest, mload(src))
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
src += WORD_SIZE;
|
|
238
|
+
dest += WORD_SIZE;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
unchecked {
|
|
242
|
+
// left over bytes. Mask is used to remove unwanted bytes from the word
|
|
243
|
+
uint256 mask = 256**(WORD_SIZE - len) - 1;
|
|
244
|
+
assembly {
|
|
245
|
+
let srcpart := and(mload(src), not(mask)) // zero out src
|
|
246
|
+
let destpart := and(mload(dest), mask) // retrieve the bytes
|
|
247
|
+
mstore(dest, or(destpart, srcpart))
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// IStateReceiver represents interface to receive state
|
|
5
|
+
interface IStateReceiver {
|
|
6
|
+
function onStateReceive(uint256 stateId, bytes calldata data) external;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// IFxMessageProcessor represents interface to process message
|
|
10
|
+
interface IFxMessageProcessor {
|
|
11
|
+
function processMessageFromRoot(
|
|
12
|
+
uint256 stateId,
|
|
13
|
+
address rootMessageSender,
|
|
14
|
+
bytes calldata data
|
|
15
|
+
) external;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @title FxChild child contract for state receiver
|
|
20
|
+
*/
|
|
21
|
+
contract FxChildMock is IStateReceiver {
|
|
22
|
+
address public fxRoot;
|
|
23
|
+
address public systemCaller;
|
|
24
|
+
|
|
25
|
+
event NewFxMessage(address rootMessageSender, address receiver, bytes data);
|
|
26
|
+
|
|
27
|
+
constructor(address _systemCaller) {
|
|
28
|
+
systemCaller = _systemCaller;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function setFxRoot(address _fxRoot) public {
|
|
32
|
+
require(fxRoot == address(0x0));
|
|
33
|
+
fxRoot = _fxRoot;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onStateReceive(uint256 stateId, bytes calldata _data) external override {
|
|
37
|
+
require(msg.sender == systemCaller, "Invalid sender: must be system super user");
|
|
38
|
+
(address rootMessageSender, address receiver, bytes memory data) = abi.decode(_data, (address, address, bytes));
|
|
39
|
+
emit NewFxMessage(rootMessageSender, receiver, data);
|
|
40
|
+
IFxMessageProcessor(receiver).processMessageFromRoot(stateId, rootMessageSender, data);
|
|
41
|
+
}
|
|
42
|
+
}
|