arr00-testing-oz-contracts 0.0.0 → 5.8.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/README.md +121 -0
- package/access/AccessControl.sol +206 -0
- package/access/IAccessControl.sol +98 -0
- package/access/Ownable.sol +100 -0
- package/access/Ownable2Step.sol +67 -0
- package/access/extensions/AccessControlDefaultAdminRules.sol +372 -0
- package/access/extensions/AccessControlEnumerable.sol +81 -0
- package/access/extensions/IAccessControlDefaultAdminRules.sol +192 -0
- package/access/extensions/IAccessControlEnumerable.sol +31 -0
- package/access/manager/AccessManaged.sol +118 -0
- package/access/manager/AccessManager.sol +781 -0
- package/access/manager/AuthorityUtils.sol +36 -0
- package/access/manager/IAccessManaged.sol +32 -0
- package/access/manager/IAccessManager.sol +410 -0
- package/access/manager/IAuthority.sol +14 -0
- package/account/Account.sol +151 -0
- package/account/extensions/draft-AccountERC7579.sol +430 -0
- package/account/extensions/draft-AccountERC7579Hooked.sol +113 -0
- package/account/extensions/draft-ERC7821.sol +70 -0
- package/account/paymaster/Paymaster.sol +170 -0
- package/account/paymaster/extensions/PaymasterERC20.sol +394 -0
- package/account/paymaster/extensions/PaymasterERC20Guarantor.sol +190 -0
- package/account/paymaster/extensions/PaymasterERC721Owner.sol +54 -0
- package/account/paymaster/extensions/PaymasterSigner.sol +125 -0
- package/account/utils/EIP7702Utils.sol +25 -0
- package/account/utils/ERC4337Utils.sol +317 -0
- package/account/utils/draft-ERC7579Utils.sol +314 -0
- package/build/contracts/AbstractSigner.json +13 -0
- package/build/contracts/AccessControl.json +239 -0
- package/build/contracts/AccessControlDefaultAdminRules.json +467 -0
- package/build/contracts/AccessControlEnumerable.json +301 -0
- package/build/contracts/AccessManaged.json +104 -0
- package/build/contracts/AccessManager.json +1189 -0
- package/build/contracts/Account.json +150 -0
- package/build/contracts/AccountERC7579.json +515 -0
- package/build/contracts/AccountERC7579Hooked.json +539 -0
- package/build/contracts/Accumulators.json +13 -0
- package/build/contracts/Address.json +25 -0
- package/build/contracts/Arrays.json +13 -0
- package/build/contracts/AuthorityUtils.json +13 -0
- package/build/contracts/Base58.json +25 -0
- package/build/contracts/Base64.json +25 -0
- package/build/contracts/BeaconProxy.json +97 -0
- package/build/contracts/BitMaps.json +13 -0
- package/build/contracts/BlockHeader.json +25 -0
- package/build/contracts/Blockhash.json +13 -0
- package/build/contracts/BridgeERC1155.json +508 -0
- package/build/contracts/BridgeERC20.json +260 -0
- package/build/contracts/BridgeERC721.json +270 -0
- package/build/contracts/BridgeERC7802.json +249 -0
- package/build/contracts/BridgeFungible.json +236 -0
- package/build/contracts/BridgeMultiToken.json +236 -0
- package/build/contracts/BridgeNonFungible.json +212 -0
- package/build/contracts/Bytes.json +13 -0
- package/build/contracts/CAIP10.json +13 -0
- package/build/contracts/CAIP2.json +13 -0
- package/build/contracts/Calldata.json +13 -0
- package/build/contracts/Checkpoints.json +19 -0
- package/build/contracts/CircularBuffer.json +19 -0
- package/build/contracts/Clones.json +19 -0
- package/build/contracts/Comparators.json +13 -0
- package/build/contracts/Context.json +13 -0
- package/build/contracts/Create2.json +19 -0
- package/build/contracts/Create3.json +19 -0
- package/build/contracts/CrosschainLinked.json +145 -0
- package/build/contracts/CrosschainRemoteExecutor.json +199 -0
- package/build/contracts/DoubleEndedQueue.json +13 -0
- package/build/contracts/ECDSA.json +41 -0
- package/build/contracts/EIP712.json +79 -0
- package/build/contracts/EIP7702Utils.json +13 -0
- package/build/contracts/ERC1155.json +428 -0
- package/build/contracts/ERC1155Burnable.json +474 -0
- package/build/contracts/ERC1155Crosschain.json +796 -0
- package/build/contracts/ERC1155Holder.json +111 -0
- package/build/contracts/ERC1155Pausable.json +477 -0
- package/build/contracts/ERC1155Supply.json +479 -0
- package/build/contracts/ERC1155URIStorage.json +428 -0
- package/build/contracts/ERC1155Utils.json +13 -0
- package/build/contracts/ERC1363.json +585 -0
- package/build/contracts/ERC1363Utils.json +36 -0
- package/build/contracts/ERC165.json +33 -0
- package/build/contracts/ERC165Checker.json +13 -0
- package/build/contracts/ERC1967Clones.json +13 -0
- package/build/contracts/ERC1967Proxy.json +84 -0
- package/build/contracts/ERC1967Utils.json +52 -0
- package/build/contracts/ERC20.json +322 -0
- package/build/contracts/ERC20Bridgeable.json +427 -0
- package/build/contracts/ERC20Burnable.json +353 -0
- package/build/contracts/ERC20Capped.json +362 -0
- package/build/contracts/ERC20Crosschain.json +573 -0
- package/build/contracts/ERC20FlashMint.json +432 -0
- package/build/contracts/ERC20Pausable.json +371 -0
- package/build/contracts/ERC20Permit.json +532 -0
- package/build/contracts/ERC20TemporaryApproval.json +346 -0
- package/build/contracts/ERC20TransferAuthorization.json +836 -0
- package/build/contracts/ERC20Votes.json +781 -0
- package/build/contracts/ERC20Wrapper.json +405 -0
- package/build/contracts/ERC2771Context.json +46 -0
- package/build/contracts/ERC2771Forwarder.json +439 -0
- package/build/contracts/ERC2981.json +126 -0
- package/build/contracts/ERC3009.json +668 -0
- package/build/contracts/ERC4337Utils.json +13 -0
- package/build/contracts/ERC4626.json +807 -0
- package/build/contracts/ERC6372Utils.json +19 -0
- package/build/contracts/ERC6909.json +415 -0
- package/build/contracts/ERC6909ContentURI.json +472 -0
- package/build/contracts/ERC6909Metadata.json +529 -0
- package/build/contracts/ERC6909TokenSupply.json +434 -0
- package/build/contracts/ERC721.json +447 -0
- package/build/contracts/ERC721Burnable.json +460 -0
- package/build/contracts/ERC721Consecutive.json +509 -0
- package/build/contracts/ERC721Crosschain.json +674 -0
- package/build/contracts/ERC721Enumerable.json +524 -0
- package/build/contracts/ERC721Holder.json +48 -0
- package/build/contracts/ERC721Pausable.json +496 -0
- package/build/contracts/ERC721Royalty.json +540 -0
- package/build/contracts/ERC721URIStorage.json +479 -0
- package/build/contracts/ERC721Utils.json +13 -0
- package/build/contracts/ERC721Votes.json +835 -0
- package/build/contracts/ERC721Wrapper.json +553 -0
- package/build/contracts/ERC7579Utils.json +119 -0
- package/build/contracts/ERC7739.json +103 -0
- package/build/contracts/ERC7739Utils.json +13 -0
- package/build/contracts/ERC7786Recipient.json +59 -0
- package/build/contracts/ERC7821.json +112 -0
- package/build/contracts/ERC7913P256Verifier.json +43 -0
- package/build/contracts/ERC7913RSAVerifier.json +43 -0
- package/build/contracts/ERC7913WebAuthnVerifier.json +43 -0
- package/build/contracts/EnumerableMap.json +36 -0
- package/build/contracts/EnumerableSet.json +13 -0
- package/build/contracts/Errors.json +51 -0
- package/build/contracts/Governor.json +1381 -0
- package/build/contracts/GovernorCountingFractional.json +1455 -0
- package/build/contracts/GovernorCountingOverridable.json +1612 -0
- package/build/contracts/GovernorCountingSimple.json +1410 -0
- package/build/contracts/GovernorCrosschain.json +1409 -0
- package/build/contracts/GovernorNoncesKeyed.json +1405 -0
- package/build/contracts/GovernorPreventLateQuorum.json +1461 -0
- package/build/contracts/GovernorProposalGuardian.json +1426 -0
- package/build/contracts/GovernorSequentialProposalId.json +1399 -0
- package/build/contracts/GovernorSettings.json +1477 -0
- package/build/contracts/GovernorStorage.json +1506 -0
- package/build/contracts/GovernorSuperQuorum.json +1429 -0
- package/build/contracts/GovernorTimelockAccess.json +1582 -0
- package/build/contracts/GovernorTimelockCompound.json +1449 -0
- package/build/contracts/GovernorTimelockControl.json +1426 -0
- package/build/contracts/GovernorVotes.json +1399 -0
- package/build/contracts/GovernorVotesQuorumFraction.json +1497 -0
- package/build/contracts/GovernorVotesSuperQuorumFraction.json +1657 -0
- package/build/contracts/Hashes.json +13 -0
- package/build/contracts/Heap.json +13 -0
- package/build/contracts/IAccessControl.json +207 -0
- package/build/contracts/IAccessControlDefaultAdminRules.json +406 -0
- package/build/contracts/IAccessControlEnumerable.json +250 -0
- package/build/contracts/IAccessManaged.json +104 -0
- package/build/contracts/IAccessManager.json +1085 -0
- package/build/contracts/IAccount.json +90 -0
- package/build/contracts/IAccountExecute.json +79 -0
- package/build/contracts/IAggregator.json +211 -0
- package/build/contracts/IAuthority.json +43 -0
- package/build/contracts/IBeacon.json +27 -0
- package/build/contracts/ICompoundTimelock.json +427 -0
- package/build/contracts/IERC1155.json +307 -0
- package/build/contracts/IERC1155Errors.json +116 -0
- package/build/contracts/IERC1155MetadataURI.json +326 -0
- package/build/contracts/IERC1155Receiver.json +111 -0
- package/build/contracts/IERC1271.json +38 -0
- package/build/contracts/IERC1363.json +385 -0
- package/build/contracts/IERC1363Receiver.json +48 -0
- package/build/contracts/IERC1363Spender.json +43 -0
- package/build/contracts/IERC165.json +33 -0
- package/build/contracts/IERC1820Implementer.json +38 -0
- package/build/contracts/IERC1820Registry.json +227 -0
- package/build/contracts/IERC1822Proxiable.json +27 -0
- package/build/contracts/IERC1967.json +59 -0
- package/build/contracts/IERC20.json +197 -0
- package/build/contracts/IERC20Errors.json +100 -0
- package/build/contracts/IERC20Metadata.json +236 -0
- package/build/contracts/IERC20Permit.json +89 -0
- package/build/contracts/IERC2309.json +45 -0
- package/build/contracts/IERC2612.json +89 -0
- package/build/contracts/IERC2981.json +62 -0
- package/build/contracts/IERC3009.json +163 -0
- package/build/contracts/IERC3009Cancel.json +66 -0
- package/build/contracts/IERC3156FlashBorrower.json +53 -0
- package/build/contracts/IERC3156FlashLender.json +91 -0
- package/build/contracts/IERC4626.json +626 -0
- package/build/contracts/IERC4906.json +331 -0
- package/build/contracts/IERC5267.json +63 -0
- package/build/contracts/IERC5313.json +27 -0
- package/build/contracts/IERC5805.json +233 -0
- package/build/contracts/IERC6372.json +40 -0
- package/build/contracts/IERC6909.json +319 -0
- package/build/contracts/IERC6909ContentURI.json +351 -0
- package/build/contracts/IERC6909Metadata.json +376 -0
- package/build/contracts/IERC6909TokenSupply.json +338 -0
- package/build/contracts/IERC721.json +299 -0
- package/build/contracts/IERC721Enumerable.json +355 -0
- package/build/contracts/IERC721Errors.json +117 -0
- package/build/contracts/IERC721Metadata.json +344 -0
- package/build/contracts/IERC721Receiver.json +48 -0
- package/build/contracts/IERC7579AccountConfig.json +65 -0
- package/build/contracts/IERC7579Execution.json +56 -0
- package/build/contracts/IERC7579Hook.json +101 -0
- package/build/contracts/IERC7579Module.json +59 -0
- package/build/contracts/IERC7579ModuleConfig.json +127 -0
- package/build/contracts/IERC7579Validator.json +159 -0
- package/build/contracts/IERC7674.json +221 -0
- package/build/contracts/IERC7751.json +40 -0
- package/build/contracts/IERC777.json +405 -0
- package/build/contracts/IERC777Recipient.json +52 -0
- package/build/contracts/IERC777Sender.json +52 -0
- package/build/contracts/IERC7786GatewaySource.json +116 -0
- package/build/contracts/IERC7786Recipient.json +43 -0
- package/build/contracts/IERC7802.json +119 -0
- package/build/contracts/IERC7821.json +51 -0
- package/build/contracts/IERC7913SignatureVerifier.json +43 -0
- package/build/contracts/IEntryPoint.json +305 -0
- package/build/contracts/IEntryPointExtra.json +80 -0
- package/build/contracts/IEntryPointNonces.json +38 -0
- package/build/contracts/IEntryPointStake.json +97 -0
- package/build/contracts/IGovernor.json +1095 -0
- package/build/contracts/IPaymaster.json +123 -0
- package/build/contracts/ITransparentUpgradeableProxy.json +77 -0
- package/build/contracts/IVotes.json +207 -0
- package/build/contracts/Initializable.json +37 -0
- package/build/contracts/InteroperableAddress.json +30 -0
- package/build/contracts/LowLevelCall.json +13 -0
- package/build/contracts/Math.json +13 -0
- package/build/contracts/Memory.json +13 -0
- package/build/contracts/MerkleProof.json +19 -0
- package/build/contracts/MerkleTree.json +35 -0
- package/build/contracts/MessageHashUtils.json +19 -0
- package/build/contracts/MultiSignerERC7913.json +176 -0
- package/build/contracts/MultiSignerERC7913Weighted.json +264 -0
- package/build/contracts/Multicall.json +49 -0
- package/build/contracts/Nonces.json +49 -0
- package/build/contracts/NoncesKeyed.json +73 -0
- package/build/contracts/Ownable.json +88 -0
- package/build/contracts/Ownable2Step.json +127 -0
- package/build/contracts/P256.json +13 -0
- package/build/contracts/Packing.json +19 -0
- package/build/contracts/Panic.json +13 -0
- package/build/contracts/Pausable.json +63 -0
- package/build/contracts/Paymaster.json +147 -0
- package/build/contracts/PaymasterERC20.json +209 -0
- package/build/contracts/PaymasterERC20Guarantor.json +234 -0
- package/build/contracts/PaymasterERC721Owner.json +160 -0
- package/build/contracts/PaymasterSigner.json +212 -0
- package/build/contracts/Proxy.json +18 -0
- package/build/contracts/ProxyAdmin.json +135 -0
- package/build/contracts/RLP.json +19 -0
- package/build/contracts/RSA.json +13 -0
- package/build/contracts/RateLimiter.json +19 -0
- package/build/contracts/ReentrancyGuard.json +19 -0
- package/build/contracts/ReentrancyGuardTransient.json +19 -0
- package/build/contracts/RelayedCall.json +13 -0
- package/build/contracts/SafeCast.json +68 -0
- package/build/contracts/SafeERC20.json +46 -0
- package/build/contracts/ShortStrings.json +30 -0
- package/build/contracts/SignatureChecker.json +13 -0
- package/build/contracts/SignedMath.json +13 -0
- package/build/contracts/SignerECDSA.json +27 -0
- package/build/contracts/SignerEIP7702.json +13 -0
- package/build/contracts/SignerERC7913.json +27 -0
- package/build/contracts/SignerP256.json +48 -0
- package/build/contracts/SignerRSA.json +32 -0
- package/build/contracts/SignerWebAuthn.json +48 -0
- package/build/contracts/SimulateCall.json +13 -0
- package/build/contracts/SlotDerivation.json +13 -0
- package/build/contracts/StorageSlot.json +13 -0
- package/build/contracts/Strings.json +40 -0
- package/build/contracts/Time.json +13 -0
- package/build/contracts/TimelockController.json +1010 -0
- package/build/contracts/TransientSlot.json +13 -0
- package/build/contracts/TransparentUpgradeableProxy.json +131 -0
- package/build/contracts/TrieProof.json +25 -0
- package/build/contracts/UUPSUpgradeable.json +119 -0
- package/build/contracts/UpgradeableBeacon.json +154 -0
- package/build/contracts/VestingWallet.json +364 -0
- package/build/contracts/VestingWalletCliff.json +367 -0
- package/build/contracts/Votes.json +402 -0
- package/build/contracts/VotesExtended.json +450 -0
- package/build/contracts/WebAuthn.json +13 -0
- package/crosschain/CrosschainLinked.sol +114 -0
- package/crosschain/CrosschainRemoteExecutor.sol +99 -0
- package/crosschain/ERC7786Recipient.sol +66 -0
- package/crosschain/bridges/BridgeERC1155.sol +131 -0
- package/crosschain/bridges/BridgeERC20.sol +42 -0
- package/crosschain/bridges/BridgeERC721.sol +62 -0
- package/crosschain/bridges/BridgeERC7802.sol +34 -0
- package/crosschain/bridges/abstract/BridgeFungible.sol +86 -0
- package/crosschain/bridges/abstract/BridgeMultiToken.sol +99 -0
- package/crosschain/bridges/abstract/BridgeNonFungible.sol +79 -0
- package/finance/VestingWallet.sol +160 -0
- package/finance/VestingWalletCliff.sol +55 -0
- package/governance/Governor.sol +825 -0
- package/governance/IGovernor.sol +454 -0
- package/governance/TimelockController.sol +470 -0
- package/governance/extensions/GovernorCountingFractional.sol +190 -0
- package/governance/extensions/GovernorCountingOverridable.sol +226 -0
- package/governance/extensions/GovernorCountingSimple.sol +96 -0
- package/governance/extensions/GovernorCrosschain.sol +31 -0
- package/governance/extensions/GovernorNoncesKeyed.sol +91 -0
- package/governance/extensions/GovernorPreventLateQuorum.sol +119 -0
- package/governance/extensions/GovernorProposalGuardian.sol +59 -0
- package/governance/extensions/GovernorSequentialProposalId.sol +75 -0
- package/governance/extensions/GovernorSettings.sol +106 -0
- package/governance/extensions/GovernorStorage.sol +134 -0
- package/governance/extensions/GovernorSuperQuorum.sol +59 -0
- package/governance/extensions/GovernorTimelockAccess.sol +346 -0
- package/governance/extensions/GovernorTimelockCompound.sol +162 -0
- package/governance/extensions/GovernorTimelockControl.sol +167 -0
- package/governance/extensions/GovernorVotes.sol +64 -0
- package/governance/extensions/GovernorVotesQuorumFraction.sol +113 -0
- package/governance/extensions/GovernorVotesSuperQuorumFraction.sol +135 -0
- package/governance/utils/IVotes.sol +60 -0
- package/governance/utils/Votes.sol +245 -0
- package/governance/utils/VotesExtended.sol +85 -0
- package/interfaces/IERC1155.sol +6 -0
- package/interfaces/IERC1155MetadataURI.sol +6 -0
- package/interfaces/IERC1155Receiver.sol +6 -0
- package/interfaces/IERC1271.sol +17 -0
- package/interfaces/IERC1363.sol +86 -0
- package/interfaces/IERC1363Receiver.sol +32 -0
- package/interfaces/IERC1363Spender.sol +26 -0
- package/interfaces/IERC165.sol +6 -0
- package/interfaces/IERC1820Implementer.sol +20 -0
- package/interfaces/IERC1820Registry.sol +112 -0
- package/interfaces/IERC1967.sol +24 -0
- package/interfaces/IERC20.sol +6 -0
- package/interfaces/IERC20Metadata.sol +6 -0
- package/interfaces/IERC2309.sol +19 -0
- package/interfaces/IERC2612.sol +8 -0
- package/interfaces/IERC2981.sol +26 -0
- package/interfaces/IERC3156.sol +7 -0
- package/interfaces/IERC3156FlashBorrower.sol +27 -0
- package/interfaces/IERC3156FlashLender.sol +41 -0
- package/interfaces/IERC4337.sol +255 -0
- package/interfaces/IERC4626.sol +230 -0
- package/interfaces/IERC4906.sol +20 -0
- package/interfaces/IERC5267.sol +28 -0
- package/interfaces/IERC5313.sol +16 -0
- package/interfaces/IERC5805.sol +9 -0
- package/interfaces/IERC6093.sol +162 -0
- package/interfaces/IERC6372.sol +19 -0
- package/interfaces/IERC6909.sol +131 -0
- package/interfaces/IERC721.sol +6 -0
- package/interfaces/IERC721Enumerable.sol +6 -0
- package/interfaces/IERC721Metadata.sol +6 -0
- package/interfaces/IERC721Receiver.sol +6 -0
- package/interfaces/IERC7751.sol +12 -0
- package/interfaces/IERC777.sol +200 -0
- package/interfaces/IERC777Recipient.sol +35 -0
- package/interfaces/IERC777Sender.sol +35 -0
- package/interfaces/IERC7786.sol +64 -0
- package/interfaces/IERC7913.sol +18 -0
- package/interfaces/draft-IERC1822.sol +20 -0
- package/interfaces/draft-IERC3009.sol +87 -0
- package/interfaces/draft-IERC7579.sol +227 -0
- package/interfaces/draft-IERC7674.sol +17 -0
- package/interfaces/draft-IERC7802.sol +32 -0
- package/interfaces/draft-IERC7821.sol +44 -0
- package/metatx/ERC2771Context.sol +90 -0
- package/metatx/ERC2771Forwarder.sol +376 -0
- package/package.json +29 -1
- package/proxy/Clones.sol +294 -0
- package/proxy/ERC1967/ERC1967Clones.sol +219 -0
- package/proxy/ERC1967/ERC1967Proxy.sol +62 -0
- package/proxy/ERC1967/ERC1967Utils.sol +177 -0
- package/proxy/Proxy.sol +69 -0
- package/proxy/beacon/BeaconProxy.sol +57 -0
- package/proxy/beacon/IBeacon.sol +16 -0
- package/proxy/beacon/UpgradeableBeacon.sol +70 -0
- package/proxy/transparent/ProxyAdmin.sol +45 -0
- package/proxy/transparent/TransparentUpgradeableProxy.sol +118 -0
- package/proxy/utils/Initializable.sol +238 -0
- package/proxy/utils/UUPSUpgradeable.sol +148 -0
- package/token/ERC1155/ERC1155.sol +417 -0
- package/token/ERC1155/IERC1155.sol +123 -0
- package/token/ERC1155/IERC1155Receiver.sol +59 -0
- package/token/ERC1155/extensions/ERC1155Burnable.sol +22 -0
- package/token/ERC1155/extensions/ERC1155Crosschain.sol +87 -0
- package/token/ERC1155/extensions/ERC1155Pausable.sol +38 -0
- package/token/ERC1155/extensions/ERC1155Supply.sol +88 -0
- package/token/ERC1155/extensions/ERC1155URIStorage.sol +58 -0
- package/token/ERC1155/extensions/IERC1155MetadataURI.sol +20 -0
- package/token/ERC1155/utils/ERC1155Holder.sol +42 -0
- package/token/ERC1155/utils/ERC1155Utils.sol +88 -0
- package/token/ERC20/ERC20.sol +305 -0
- package/token/ERC20/IERC20.sol +79 -0
- package/token/ERC20/extensions/ERC1363.sol +135 -0
- package/token/ERC20/extensions/ERC20Burnable.sol +38 -0
- package/token/ERC20/extensions/ERC20Capped.sol +54 -0
- package/token/ERC20/extensions/ERC20Crosschain.sol +39 -0
- package/token/ERC20/extensions/ERC20FlashMint.sol +130 -0
- package/token/ERC20/extensions/ERC20Pausable.sol +33 -0
- package/token/ERC20/extensions/ERC20Permit.sol +77 -0
- package/token/ERC20/extensions/ERC20TransferAuthorization.sol +91 -0
- package/token/ERC20/extensions/ERC20Votes.sol +83 -0
- package/token/ERC20/extensions/ERC20Wrapper.sol +93 -0
- package/token/ERC20/extensions/ERC4626.sol +304 -0
- package/token/ERC20/extensions/IERC20Metadata.sol +26 -0
- package/token/ERC20/extensions/IERC20Permit.sol +90 -0
- package/token/ERC20/extensions/draft-ERC20Bridgeable.sol +51 -0
- package/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol +119 -0
- package/token/ERC20/extensions/draft-ERC3009.sol +152 -0
- package/token/ERC20/utils/ERC1363Utils.sol +95 -0
- package/token/ERC20/utils/SafeERC20.sol +292 -0
- package/token/ERC6909/ERC6909.sol +224 -0
- package/token/ERC6909/extensions/ERC6909ContentURI.sol +59 -0
- package/token/ERC6909/extensions/ERC6909Metadata.sol +83 -0
- package/token/ERC6909/extensions/ERC6909TokenSupply.sol +41 -0
- package/token/ERC721/ERC721.sol +433 -0
- package/token/ERC721/IERC721.sol +135 -0
- package/token/ERC721/IERC721Receiver.sol +28 -0
- package/token/ERC721/extensions/ERC721Burnable.sol +26 -0
- package/token/ERC721/extensions/ERC721Consecutive.sol +176 -0
- package/token/ERC721/extensions/ERC721Crosschain.sol +38 -0
- package/token/ERC721/extensions/ERC721Enumerable.sol +165 -0
- package/token/ERC721/extensions/ERC721Pausable.sol +37 -0
- package/token/ERC721/extensions/ERC721Royalty.sol +26 -0
- package/token/ERC721/extensions/ERC721URIStorage.sol +62 -0
- package/token/ERC721/extensions/ERC721Votes.sol +47 -0
- package/token/ERC721/extensions/ERC721Wrapper.sol +102 -0
- package/token/ERC721/extensions/IERC721Enumerable.sol +29 -0
- package/token/ERC721/extensions/IERC721Metadata.sol +27 -0
- package/token/ERC721/utils/ERC721Holder.sol +26 -0
- package/token/ERC721/utils/ERC721Utils.sol +50 -0
- package/token/common/ERC2981.sol +140 -0
- package/utils/Address.sol +167 -0
- package/utils/Arrays.sol +905 -0
- package/utils/Base58.sol +240 -0
- package/utils/Base64.sol +234 -0
- package/utils/BlockHeader.sol +312 -0
- package/utils/Blockhash.sol +54 -0
- package/utils/Bytes.sol +329 -0
- package/utils/CAIP10.sol +54 -0
- package/utils/CAIP2.sol +51 -0
- package/utils/Calldata.sol +25 -0
- package/utils/Comparators.sol +19 -0
- package/utils/Context.sol +28 -0
- package/utils/Create2.sol +91 -0
- package/utils/Create3.sol +133 -0
- package/utils/ERC6372Utils.sol +53 -0
- package/utils/Errors.sol +34 -0
- package/utils/LowLevelCall.sol +127 -0
- package/utils/Memory.sol +151 -0
- package/utils/Multicall.sol +37 -0
- package/utils/Nonces.sol +47 -0
- package/utils/NoncesKeyed.sol +75 -0
- package/utils/Packing.sol +1656 -0
- package/utils/Panic.sol +57 -0
- package/utils/Pausable.sol +112 -0
- package/utils/RLP.sol +487 -0
- package/utils/RateLimiter.sol +310 -0
- package/utils/ReentrancyGuard.sol +119 -0
- package/utils/ReentrancyGuardTransient.sol +84 -0
- package/utils/RelayedCall.sol +145 -0
- package/utils/ShortStrings.sol +122 -0
- package/utils/SimulateCall.sol +114 -0
- package/utils/SlotDerivation.sol +155 -0
- package/utils/StorageSlot.sol +143 -0
- package/utils/Strings.sol +532 -0
- package/utils/TransientSlot.sol +183 -0
- package/utils/cryptography/ECDSA.sol +284 -0
- package/utils/cryptography/EIP712.sol +168 -0
- package/utils/cryptography/Hashes.sol +31 -0
- package/utils/cryptography/MerkleProof.sol +510 -0
- package/utils/cryptography/MessageHashUtils.sol +228 -0
- package/utils/cryptography/P256.sol +409 -0
- package/utils/cryptography/RSA.sol +159 -0
- package/utils/cryptography/SignatureChecker.sol +199 -0
- package/utils/cryptography/TrieProof.sol +256 -0
- package/utils/cryptography/WebAuthn.sol +269 -0
- package/utils/cryptography/draft-ERC7739Utils.sol +215 -0
- package/utils/cryptography/signers/AbstractSigner.sol +23 -0
- package/utils/cryptography/signers/MultiSignerERC7913.sol +336 -0
- package/utils/cryptography/signers/MultiSignerERC7913Weighted.sol +208 -0
- package/utils/cryptography/signers/SignerECDSA.sol +56 -0
- package/utils/cryptography/signers/SignerEIP7702.sol +25 -0
- package/utils/cryptography/signers/SignerERC7913.sol +63 -0
- package/utils/cryptography/signers/SignerP256.sol +64 -0
- package/utils/cryptography/signers/SignerRSA.sol +65 -0
- package/utils/cryptography/signers/SignerWebAuthn.sol +45 -0
- package/utils/cryptography/signers/draft-ERC7739.sol +99 -0
- package/utils/cryptography/verifiers/ERC7913P256Verifier.sol +29 -0
- package/utils/cryptography/verifiers/ERC7913RSAVerifier.sol +23 -0
- package/utils/cryptography/verifiers/ERC7913WebAuthnVerifier.sol +45 -0
- package/utils/draft-InteroperableAddress.sol +245 -0
- package/utils/introspection/ERC165.sol +25 -0
- package/utils/introspection/ERC165Checker.sol +142 -0
- package/utils/introspection/IERC165.sol +25 -0
- package/utils/math/Math.sol +763 -0
- package/utils/math/SafeCast.sol +1162 -0
- package/utils/math/SignedMath.sol +68 -0
- package/utils/structs/Accumulators.sol +135 -0
- package/utils/structs/BitMaps.sol +61 -0
- package/utils/structs/Checkpoints.sol +881 -0
- package/utils/structs/CircularBuffer.sol +152 -0
- package/utils/structs/DoubleEndedQueue.sol +280 -0
- package/utils/structs/EnumerableMap.sol +1870 -0
- package/utils/structs/EnumerableSet.sol +1177 -0
- package/utils/structs/Heap.sol +259 -0
- package/utils/structs/MerkleTree.sol +267 -0
- package/utils/types/Time.sol +133 -0
- package/vendor/compound/ICompoundTimelock.sol +86 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v5.8.0) (governance/extensions/GovernorTimelockAccess.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.24;
|
|
5
|
+
|
|
6
|
+
import {AuthorityUtils} from "../../access/manager/AuthorityUtils.sol";
|
|
7
|
+
import {IAccessManager} from "../../access/manager/IAccessManager.sol";
|
|
8
|
+
import {Address} from "../../utils/Address.sol";
|
|
9
|
+
import {Math} from "../../utils/math/Math.sol";
|
|
10
|
+
import {SafeCast} from "../../utils/math/SafeCast.sol";
|
|
11
|
+
import {Time} from "../../utils/types/Time.sol";
|
|
12
|
+
import {IGovernor, Governor} from "../Governor.sol";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @dev This module connects a {Governor} instance to an {AccessManager} instance, allowing the governor to make calls
|
|
16
|
+
* that are delay-restricted by the manager using the normal {queue} workflow. An optional base delay is applied to
|
|
17
|
+
* operations that are not delayed externally by the manager. Execution of a proposal will be delayed as much as
|
|
18
|
+
* necessary to meet the required delays of all of its operations.
|
|
19
|
+
*
|
|
20
|
+
* This extension allows the governor to hold and use its own assets and permissions, unlike {GovernorTimelockControl}
|
|
21
|
+
* and {GovernorTimelockCompound}, where the timelock is a separate contract that must be the one to hold assets and
|
|
22
|
+
* permissions. Operations that are delay-restricted by the manager, however, will be executed through the
|
|
23
|
+
* {AccessManager-execute} function.
|
|
24
|
+
*
|
|
25
|
+
* ==== Security Considerations
|
|
26
|
+
*
|
|
27
|
+
* Some operations may be cancelable in the `AccessManager` by the admin or a set of guardians, depending on the
|
|
28
|
+
* restricted function being invoked. Since proposals are atomic, the cancellation by a guardian of a single operation
|
|
29
|
+
* in a proposal will cause all of the proposal to become unable to execute. Consider proposing cancellable operations
|
|
30
|
+
* separately.
|
|
31
|
+
*
|
|
32
|
+
* By default, function calls will be routed through the associated `AccessManager` whenever it claims the target
|
|
33
|
+
* function to be restricted by it. However, admins may configure the manager to make that claim for functions that a
|
|
34
|
+
* governor would want to call directly (e.g., token transfers) in an attempt to deny it access to those functions. To
|
|
35
|
+
* mitigate this attack vector, the governor is able to ignore the restrictions claimed by the `AccessManager` using
|
|
36
|
+
* {setAccessManagerIgnored}. While permanent denial of service is mitigated, temporary DoS may still be technically
|
|
37
|
+
* possible. All of the governor's own functions (e.g., {setBaseDelaySeconds}) ignore the `AccessManager` by default.
|
|
38
|
+
*
|
|
39
|
+
* NOTE: `AccessManager` does not support scheduling more than one operation with the same target and calldata at
|
|
40
|
+
* the same time. See {AccessManager-schedule} for a workaround.
|
|
41
|
+
*/
|
|
42
|
+
abstract contract GovernorTimelockAccess is Governor {
|
|
43
|
+
// An execution plan is produced at the moment a proposal is created, in order to fix at that point the exact
|
|
44
|
+
// execution semantics of the proposal, namely whether a call will go through {AccessManager-execute}.
|
|
45
|
+
struct ExecutionPlan {
|
|
46
|
+
uint16 length;
|
|
47
|
+
uint32 delay;
|
|
48
|
+
// We use mappings instead of arrays because it allows us to pack values in storage more tightly without
|
|
49
|
+
// storing the length redundantly.
|
|
50
|
+
// We pack 8 operations' data in each bucket. Each uint32 value is set to 1 upon proposal creation if it has
|
|
51
|
+
// to be scheduled and executed through the manager. Upon queuing, the value is set to nonce + 2, where the
|
|
52
|
+
// nonce is received from the manager when scheduling the operation.
|
|
53
|
+
mapping(uint256 operationBucket => uint32[8]) managerData;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The meaning of the "toggle" set to true depends on the target contract.
|
|
57
|
+
// If target == address(this), the manager is ignored by default, and a true toggle means it won't be ignored.
|
|
58
|
+
// For all other target contracts, the manager is used by default, and a true toggle means it will be ignored.
|
|
59
|
+
mapping(address target => mapping(bytes4 selector => bool)) private _ignoreToggle;
|
|
60
|
+
|
|
61
|
+
mapping(uint256 proposalId => ExecutionPlan) private _executionPlan;
|
|
62
|
+
|
|
63
|
+
uint32 private _baseDelay;
|
|
64
|
+
|
|
65
|
+
IAccessManager private immutable _manager;
|
|
66
|
+
|
|
67
|
+
error GovernorUnmetDelay(uint256 proposalId, uint256 neededTimestamp);
|
|
68
|
+
error GovernorMismatchedNonce(uint256 proposalId, uint256 expectedNonce, uint256 actualNonce);
|
|
69
|
+
error GovernorLockedIgnore();
|
|
70
|
+
|
|
71
|
+
event BaseDelaySet(uint32 oldBaseDelaySeconds, uint32 newBaseDelaySeconds);
|
|
72
|
+
event AccessManagerIgnoredSet(address target, bytes4 selector, bool ignored);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @dev Initialize the governor with an {AccessManager} and initial base delay.
|
|
76
|
+
*/
|
|
77
|
+
constructor(address manager, uint32 initialBaseDelay) {
|
|
78
|
+
_manager = IAccessManager(manager);
|
|
79
|
+
_setBaseDelaySeconds(initialBaseDelay);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @dev Returns the {AccessManager} instance associated to this governor.
|
|
84
|
+
*/
|
|
85
|
+
function accessManager() public view virtual returns (IAccessManager) {
|
|
86
|
+
return _manager;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @dev Base delay that will be applied to all function calls. Some may be further delayed by their associated
|
|
91
|
+
* `AccessManager` authority; in this case the final delay will be the maximum of the base delay and the one
|
|
92
|
+
* demanded by the authority.
|
|
93
|
+
*
|
|
94
|
+
* NOTE: Execution delays are processed by the `AccessManager` contracts, and according to that contract are
|
|
95
|
+
* expressed in seconds. Therefore, the base delay is also in seconds, regardless of the governor's clock mode.
|
|
96
|
+
*/
|
|
97
|
+
function baseDelaySeconds() public view virtual returns (uint32) {
|
|
98
|
+
return _baseDelay;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @dev Change the value of {baseDelaySeconds}. This operation can only be invoked through a governance proposal.
|
|
103
|
+
*/
|
|
104
|
+
function setBaseDelaySeconds(uint32 newBaseDelay) public virtual onlyGovernance {
|
|
105
|
+
_setBaseDelaySeconds(newBaseDelay);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @dev Change the value of {baseDelaySeconds}. Internal function without access control.
|
|
110
|
+
*/
|
|
111
|
+
function _setBaseDelaySeconds(uint32 newBaseDelay) internal virtual {
|
|
112
|
+
emit BaseDelaySet(_baseDelay, newBaseDelay);
|
|
113
|
+
_baseDelay = newBaseDelay;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @dev Check if restrictions from the associated {AccessManager} are ignored for a target function. Returns true
|
|
118
|
+
* when the target function will be invoked directly regardless of `AccessManager` settings for the function.
|
|
119
|
+
* See {setAccessManagerIgnored} and Security Considerations above.
|
|
120
|
+
*/
|
|
121
|
+
function isAccessManagerIgnored(address target, bytes4 selector) public view virtual returns (bool) {
|
|
122
|
+
bool isGovernor = target == address(this);
|
|
123
|
+
return _ignoreToggle[target][selector] != isGovernor; // equivalent to: isGovernor ? !toggle : toggle
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @dev Configure whether restrictions from the associated {AccessManager} are ignored for a target function.
|
|
128
|
+
* See Security Considerations above.
|
|
129
|
+
*/
|
|
130
|
+
function setAccessManagerIgnored(
|
|
131
|
+
address target,
|
|
132
|
+
bytes4[] calldata selectors,
|
|
133
|
+
bool ignored
|
|
134
|
+
) public virtual onlyGovernance {
|
|
135
|
+
for (uint256 i = 0; i < selectors.length; ++i) {
|
|
136
|
+
_setAccessManagerIgnored(target, selectors[i], ignored);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @dev Internal version of {setAccessManagerIgnored} without access restriction.
|
|
142
|
+
*/
|
|
143
|
+
function _setAccessManagerIgnored(address target, bytes4 selector, bool ignored) internal virtual {
|
|
144
|
+
bool isGovernor = target == address(this);
|
|
145
|
+
if (isGovernor && selector == this.setAccessManagerIgnored.selector) {
|
|
146
|
+
revert GovernorLockedIgnore();
|
|
147
|
+
}
|
|
148
|
+
_ignoreToggle[target][selector] = ignored != isGovernor; // equivalent to: isGovernor ? !ignored : ignored
|
|
149
|
+
emit AccessManagerIgnoredSet(target, selector, ignored);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @dev Public accessor to check the execution plan, including the number of seconds that the proposal will be
|
|
154
|
+
* delayed since queuing, an array indicating which of the proposal actions will be executed indirectly through
|
|
155
|
+
* the associated {AccessManager}, and another indicating which will be scheduled in {queue}. Note that
|
|
156
|
+
* those that must be scheduled are cancellable by `AccessManager` guardians.
|
|
157
|
+
*/
|
|
158
|
+
function proposalExecutionPlan(
|
|
159
|
+
uint256 proposalId
|
|
160
|
+
) public view returns (uint32 delay, bool[] memory indirect, bool[] memory withDelay) {
|
|
161
|
+
ExecutionPlan storage plan = _executionPlan[proposalId];
|
|
162
|
+
|
|
163
|
+
uint32 length = plan.length;
|
|
164
|
+
delay = plan.delay;
|
|
165
|
+
indirect = new bool[](length);
|
|
166
|
+
withDelay = new bool[](length);
|
|
167
|
+
for (uint256 i = 0; i < length; ++i) {
|
|
168
|
+
(indirect[i], withDelay[i], ) = _getManagerData(plan, i);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return (delay, indirect, withDelay);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/// @inheritdoc IGovernor
|
|
175
|
+
function proposalNeedsQueuing(uint256 proposalId) public view virtual override returns (bool) {
|
|
176
|
+
return _executionPlan[proposalId].delay > 0;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// @inheritdoc IGovernor
|
|
180
|
+
function propose(
|
|
181
|
+
address[] memory targets,
|
|
182
|
+
uint256[] memory values,
|
|
183
|
+
bytes[] memory calldatas,
|
|
184
|
+
string memory description
|
|
185
|
+
) public virtual override returns (uint256) {
|
|
186
|
+
uint256 proposalId = super.propose(targets, values, calldatas, description);
|
|
187
|
+
|
|
188
|
+
uint32 neededDelay = baseDelaySeconds();
|
|
189
|
+
|
|
190
|
+
ExecutionPlan storage plan = _executionPlan[proposalId];
|
|
191
|
+
plan.length = SafeCast.toUint16(targets.length);
|
|
192
|
+
|
|
193
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
194
|
+
if (calldatas[i].length < 4) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
address target = targets[i];
|
|
198
|
+
bytes4 selector = bytes4(calldatas[i]);
|
|
199
|
+
(bool immediate, uint32 delay) = AuthorityUtils.canCallWithDelay(
|
|
200
|
+
address(_manager),
|
|
201
|
+
address(this),
|
|
202
|
+
target,
|
|
203
|
+
selector
|
|
204
|
+
);
|
|
205
|
+
if ((immediate || delay > 0) && !isAccessManagerIgnored(target, selector)) {
|
|
206
|
+
_setManagerData(plan, i, !immediate, 0);
|
|
207
|
+
// downcast is safe because both arguments are uint32
|
|
208
|
+
neededDelay = uint32(Math.max(delay, neededDelay));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
plan.delay = neededDelay;
|
|
213
|
+
|
|
214
|
+
return proposalId;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @dev Mechanism to queue a proposal, potentially scheduling some of its operations in the AccessManager.
|
|
219
|
+
*
|
|
220
|
+
* NOTE: The execution delay is chosen based on the delay information retrieved in {propose}. This value may be
|
|
221
|
+
* off if the delay was updated since proposal creation. In this case, the proposal needs to be recreated.
|
|
222
|
+
*/
|
|
223
|
+
function _queueOperations(
|
|
224
|
+
uint256 proposalId,
|
|
225
|
+
address[] memory targets,
|
|
226
|
+
uint256[] memory /* values */,
|
|
227
|
+
bytes[] memory calldatas,
|
|
228
|
+
bytes32 /* descriptionHash */
|
|
229
|
+
) internal virtual override returns (uint48) {
|
|
230
|
+
ExecutionPlan storage plan = _executionPlan[proposalId];
|
|
231
|
+
uint48 etaSeconds = Time.timestamp() + plan.delay;
|
|
232
|
+
|
|
233
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
234
|
+
(, bool withDelay, ) = _getManagerData(plan, i);
|
|
235
|
+
if (withDelay) {
|
|
236
|
+
// This function can reenter when calling `_manager.schedule` before performing state updates in `_setManagerData`.
|
|
237
|
+
// However, the `manager` is a trusted contract in the current context's security model (e.g. an `AccessManager`).
|
|
238
|
+
// slither-disable-next-line reentrancy-no-eth
|
|
239
|
+
(, uint32 nonce) = _manager.schedule(targets[i], calldatas[i], etaSeconds);
|
|
240
|
+
_setManagerData(plan, i, true, nonce);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return etaSeconds;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @dev Mechanism to execute a proposal, potentially going through {AccessManager-execute} for delayed operations.
|
|
249
|
+
*/
|
|
250
|
+
function _executeOperations(
|
|
251
|
+
uint256 proposalId,
|
|
252
|
+
address[] memory targets,
|
|
253
|
+
uint256[] memory values,
|
|
254
|
+
bytes[] memory calldatas,
|
|
255
|
+
bytes32 /* descriptionHash */
|
|
256
|
+
) internal virtual override {
|
|
257
|
+
uint48 etaSeconds = SafeCast.toUint48(proposalEta(proposalId));
|
|
258
|
+
if (block.timestamp < etaSeconds) {
|
|
259
|
+
revert GovernorUnmetDelay(proposalId, etaSeconds);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
ExecutionPlan storage plan = _executionPlan[proposalId];
|
|
263
|
+
|
|
264
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
265
|
+
(bool controlled, bool withDelay, uint32 nonce) = _getManagerData(plan, i);
|
|
266
|
+
if (controlled) {
|
|
267
|
+
uint32 executedNonce = _manager.execute{value: values[i]}(targets[i], calldatas[i]);
|
|
268
|
+
if (withDelay && executedNonce != nonce) {
|
|
269
|
+
revert GovernorMismatchedNonce(proposalId, nonce, executedNonce);
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
(bool success, bytes memory returndata) = targets[i].call{value: values[i]}(calldatas[i]);
|
|
273
|
+
Address.verifyCallResult(success, returndata);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/// @inheritdoc Governor
|
|
279
|
+
function _cancel(
|
|
280
|
+
address[] memory targets,
|
|
281
|
+
uint256[] memory values,
|
|
282
|
+
bytes[] memory calldatas,
|
|
283
|
+
bytes32 descriptionHash
|
|
284
|
+
) internal virtual override returns (uint256) {
|
|
285
|
+
uint256 proposalId = super._cancel(targets, values, calldatas, descriptionHash);
|
|
286
|
+
|
|
287
|
+
uint48 etaSeconds = SafeCast.toUint48(proposalEta(proposalId));
|
|
288
|
+
|
|
289
|
+
ExecutionPlan storage plan = _executionPlan[proposalId];
|
|
290
|
+
|
|
291
|
+
// If the proposal has been scheduled it will have an ETA and we may have to externally cancel
|
|
292
|
+
if (etaSeconds != 0) {
|
|
293
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
294
|
+
(, bool withDelay, uint32 nonce) = _getManagerData(plan, i);
|
|
295
|
+
// Only attempt to cancel if the execution plan included a delay
|
|
296
|
+
if (withDelay) {
|
|
297
|
+
bytes32 operationId = _manager.hashOperation(address(this), targets[i], calldatas[i]);
|
|
298
|
+
// Check first if the current operation nonce is the one that we observed previously. It could
|
|
299
|
+
// already have been cancelled and rescheduled. We don't want to cancel unless it is exactly the
|
|
300
|
+
// instance that we previously scheduled.
|
|
301
|
+
if (nonce == _manager.getNonce(operationId)) {
|
|
302
|
+
// It is important that all calls have an opportunity to be cancelled. We chose to ignore
|
|
303
|
+
// potential failures of some of the cancel operations to give the other operations a chance to
|
|
304
|
+
// be properly cancelled. In particular cancel might fail if the operation was already cancelled
|
|
305
|
+
// by guardians previously. We don't match on the revert reason to avoid encoding assumptions
|
|
306
|
+
// about specific errors.
|
|
307
|
+
try _manager.cancel(address(this), targets[i], calldatas[i]) {} catch {}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return proposalId;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* @dev Returns whether the operation at an index is delayed by the manager, and its scheduling nonce once queued.
|
|
318
|
+
*/
|
|
319
|
+
function _getManagerData(
|
|
320
|
+
ExecutionPlan storage plan,
|
|
321
|
+
uint256 index
|
|
322
|
+
) private view returns (bool controlled, bool withDelay, uint32 nonce) {
|
|
323
|
+
(uint256 bucket, uint256 subindex) = _getManagerDataIndices(index);
|
|
324
|
+
uint32 value = plan.managerData[bucket][subindex];
|
|
325
|
+
unchecked {
|
|
326
|
+
return (value > 0, value > 1, value > 1 ? value - 2 : 0);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @dev Marks an operation at an index as permissioned by the manager, potentially delayed, and
|
|
332
|
+
* when delayed sets its scheduling nonce.
|
|
333
|
+
*/
|
|
334
|
+
function _setManagerData(ExecutionPlan storage plan, uint256 index, bool withDelay, uint32 nonce) private {
|
|
335
|
+
(uint256 bucket, uint256 subindex) = _getManagerDataIndices(index);
|
|
336
|
+
plan.managerData[bucket][subindex] = withDelay ? nonce + 2 : 1;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @dev Returns bucket and subindex for reading manager data from the packed array mapping.
|
|
341
|
+
*/
|
|
342
|
+
function _getManagerDataIndices(uint256 index) private pure returns (uint256 bucket, uint256 subindex) {
|
|
343
|
+
bucket = index >> 3; // index / 8
|
|
344
|
+
subindex = index & 7; // index % 8
|
|
345
|
+
}
|
|
346
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v5.8.0) (governance/extensions/GovernorTimelockCompound.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.24;
|
|
5
|
+
|
|
6
|
+
import {Address} from "../../utils/Address.sol";
|
|
7
|
+
import {SafeCast} from "../../utils/math/SafeCast.sol";
|
|
8
|
+
import {ICompoundTimelock} from "../../vendor/compound/ICompoundTimelock.sol";
|
|
9
|
+
import {IGovernor, Governor} from "../Governor.sol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @dev Extension of {Governor} that binds the execution process to a Compound Timelock. This adds a delay, enforced by
|
|
13
|
+
* the external timelock to all successful proposals (in addition to the voting duration). The {Governor} needs to be
|
|
14
|
+
* the admin of the timelock for any operation to be performed. A public, unrestricted,
|
|
15
|
+
* {GovernorTimelockCompound-__acceptAdmin} is available to accept ownership of the timelock.
|
|
16
|
+
*
|
|
17
|
+
* Using this model means the proposal will be operated by the {ICompoundTimelock} and not by the {Governor}. Thus,
|
|
18
|
+
* the assets and permissions must be attached to the {ICompoundTimelock}. Any asset sent to the {Governor} will be
|
|
19
|
+
* inaccessible from a proposal, unless executed via {Governor-relay}.
|
|
20
|
+
*/
|
|
21
|
+
abstract contract GovernorTimelockCompound is Governor {
|
|
22
|
+
ICompoundTimelock private _timelock;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @dev Emitted when the timelock used for proposal execution is modified.
|
|
26
|
+
*/
|
|
27
|
+
event TimelockChange(address oldTimelock, address newTimelock);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @dev Set the timelock.
|
|
31
|
+
*/
|
|
32
|
+
constructor(ICompoundTimelock timelockAddress) {
|
|
33
|
+
_updateTimelock(timelockAddress);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @dev Overridden version of the {Governor-state} function with added support for the `Expired` state.
|
|
38
|
+
*/
|
|
39
|
+
function state(uint256 proposalId) public view virtual override returns (ProposalState) {
|
|
40
|
+
ProposalState currentState = super.state(proposalId);
|
|
41
|
+
|
|
42
|
+
return
|
|
43
|
+
(currentState == ProposalState.Queued &&
|
|
44
|
+
block.timestamp >= proposalEta(proposalId) + _timelock.GRACE_PERIOD())
|
|
45
|
+
? ProposalState.Expired
|
|
46
|
+
: currentState;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @dev Public accessor to check the address of the timelock
|
|
51
|
+
*/
|
|
52
|
+
function timelock() public view virtual returns (address) {
|
|
53
|
+
return address(_timelock);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// @inheritdoc IGovernor
|
|
57
|
+
function proposalNeedsQueuing(uint256) public view virtual override returns (bool) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @dev Function to queue a proposal to the timelock.
|
|
63
|
+
*/
|
|
64
|
+
function _queueOperations(
|
|
65
|
+
uint256 proposalId,
|
|
66
|
+
address[] memory targets,
|
|
67
|
+
uint256[] memory values,
|
|
68
|
+
bytes[] memory calldatas,
|
|
69
|
+
bytes32 /*descriptionHash*/
|
|
70
|
+
) internal virtual override returns (uint48) {
|
|
71
|
+
uint48 etaSeconds = SafeCast.toUint48(block.timestamp + _timelock.delay());
|
|
72
|
+
|
|
73
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
74
|
+
if (
|
|
75
|
+
_timelock.queuedTransactions(keccak256(abi.encode(targets[i], values[i], "", calldatas[i], etaSeconds)))
|
|
76
|
+
) {
|
|
77
|
+
revert GovernorAlreadyQueuedProposal(proposalId);
|
|
78
|
+
}
|
|
79
|
+
_timelock.queueTransaction(targets[i], values[i], "", calldatas[i], etaSeconds);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return etaSeconds;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @dev Overridden version of the {Governor-_executeOperations} function that run the already queued proposal
|
|
87
|
+
* through the timelock.
|
|
88
|
+
*/
|
|
89
|
+
function _executeOperations(
|
|
90
|
+
uint256 proposalId,
|
|
91
|
+
address[] memory targets,
|
|
92
|
+
uint256[] memory values,
|
|
93
|
+
bytes[] memory calldatas,
|
|
94
|
+
bytes32 /*descriptionHash*/
|
|
95
|
+
) internal virtual override {
|
|
96
|
+
uint256 etaSeconds = proposalEta(proposalId);
|
|
97
|
+
Address.sendValue(payable(_timelock), msg.value);
|
|
98
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
99
|
+
_timelock.executeTransaction(targets[i], values[i], "", calldatas[i], etaSeconds);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @dev Overridden version of the {Governor-_cancel} function to cancel the timelocked proposal if it has already
|
|
105
|
+
* been queued.
|
|
106
|
+
*/
|
|
107
|
+
function _cancel(
|
|
108
|
+
address[] memory targets,
|
|
109
|
+
uint256[] memory values,
|
|
110
|
+
bytes[] memory calldatas,
|
|
111
|
+
bytes32 descriptionHash
|
|
112
|
+
) internal virtual override returns (uint256) {
|
|
113
|
+
uint256 proposalId = super._cancel(targets, values, calldatas, descriptionHash);
|
|
114
|
+
|
|
115
|
+
uint256 etaSeconds = proposalEta(proposalId);
|
|
116
|
+
if (etaSeconds > 0) {
|
|
117
|
+
// do external call later
|
|
118
|
+
for (uint256 i = 0; i < targets.length; ++i) {
|
|
119
|
+
_timelock.cancelTransaction(targets[i], values[i], "", calldatas[i], etaSeconds);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return proposalId;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @dev Address through which the governor executes action. In this case, the timelock.
|
|
128
|
+
*/
|
|
129
|
+
function _executor() internal view virtual override returns (address) {
|
|
130
|
+
return address(_timelock);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @dev Accept admin right over the timelock.
|
|
135
|
+
*/
|
|
136
|
+
// solhint-disable-next-line openzeppelin/leading-underscore
|
|
137
|
+
function __acceptAdmin() public {
|
|
138
|
+
_timelock.acceptAdmin();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @dev Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates
|
|
143
|
+
* must be proposed, scheduled, and executed through governance proposals.
|
|
144
|
+
*
|
|
145
|
+
* For security reasons, the timelock must be handed over to another admin before setting up a new one. The two
|
|
146
|
+
* operations (hand over the timelock) and do the update can be batched in a single proposal.
|
|
147
|
+
*
|
|
148
|
+
* Note that if the timelock admin has been handed over in a previous operation, we refuse updates made through the
|
|
149
|
+
* timelock if admin of the timelock has already been accepted and the operation is executed outside the scope of
|
|
150
|
+
* governance.
|
|
151
|
+
|
|
152
|
+
* CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.
|
|
153
|
+
*/
|
|
154
|
+
function updateTimelock(ICompoundTimelock newTimelock) public virtual onlyGovernance {
|
|
155
|
+
_updateTimelock(newTimelock);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function _updateTimelock(ICompoundTimelock newTimelock) private {
|
|
159
|
+
emit TimelockChange(address(_timelock), address(newTimelock));
|
|
160
|
+
_timelock = newTimelock;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v5.8.0) (governance/extensions/GovernorTimelockControl.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.24;
|
|
5
|
+
|
|
6
|
+
import {SafeCast} from "../../utils/math/SafeCast.sol";
|
|
7
|
+
import {IGovernor, Governor} from "../Governor.sol";
|
|
8
|
+
import {TimelockController} from "../TimelockController.sol";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @dev Extension of {Governor} that binds the execution process to an instance of {TimelockController}. This adds a
|
|
12
|
+
* delay, enforced by the {TimelockController} to all successful proposals (in addition to the voting duration). The
|
|
13
|
+
* {Governor} needs the proposer (and ideally the executor and canceller) roles for the {Governor} to work properly.
|
|
14
|
+
*
|
|
15
|
+
* Using this model means the proposal will be operated by the {TimelockController} and not by the {Governor}. Thus,
|
|
16
|
+
* the assets and permissions must be attached to the {TimelockController}. Any asset sent to the {Governor} will be
|
|
17
|
+
* inaccessible from a proposal, unless executed via {Governor-relay}.
|
|
18
|
+
*
|
|
19
|
+
* WARNING: Setting up the TimelockController to have additional proposers or cancelers besides the governor is very
|
|
20
|
+
* risky, as it grants them the ability to: 1) execute operations as the timelock, and thus possibly performing
|
|
21
|
+
* operations or accessing funds that are expected to only be accessible through a vote, and 2) block governance
|
|
22
|
+
* proposals that have been approved by the voters, effectively executing a Denial of Service attack.
|
|
23
|
+
*/
|
|
24
|
+
abstract contract GovernorTimelockControl is Governor {
|
|
25
|
+
TimelockController private _timelock;
|
|
26
|
+
mapping(uint256 proposalId => bytes32) private _timelockIds;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @dev Emitted when the timelock controller used for proposal execution is modified.
|
|
30
|
+
*/
|
|
31
|
+
event TimelockChange(address oldTimelock, address newTimelock);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @dev Set the timelock.
|
|
35
|
+
*/
|
|
36
|
+
constructor(TimelockController timelockAddress) {
|
|
37
|
+
_updateTimelock(timelockAddress);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @dev Overridden version of the {Governor-state} function that considers the status reported by the timelock.
|
|
42
|
+
*/
|
|
43
|
+
function state(uint256 proposalId) public view virtual override returns (ProposalState) {
|
|
44
|
+
ProposalState currentState = super.state(proposalId);
|
|
45
|
+
|
|
46
|
+
if (currentState != ProposalState.Queued) {
|
|
47
|
+
return currentState;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
bytes32 queueId = _timelockIds[proposalId];
|
|
51
|
+
if (_timelock.isOperationPending(queueId)) {
|
|
52
|
+
return ProposalState.Queued;
|
|
53
|
+
} else if (_timelock.isOperationDone(queueId)) {
|
|
54
|
+
// This can happen if the proposal is executed directly on the timelock.
|
|
55
|
+
return ProposalState.Executed;
|
|
56
|
+
} else {
|
|
57
|
+
// This can happen if the proposal is canceled directly on the timelock.
|
|
58
|
+
return ProposalState.Canceled;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @dev Public accessor to check the address of the timelock
|
|
64
|
+
*/
|
|
65
|
+
function timelock() public view virtual returns (address) {
|
|
66
|
+
return address(_timelock);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// @inheritdoc IGovernor
|
|
70
|
+
function proposalNeedsQueuing(uint256) public view virtual override returns (bool) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @dev Function to queue a proposal to the timelock.
|
|
76
|
+
*/
|
|
77
|
+
function _queueOperations(
|
|
78
|
+
uint256 proposalId,
|
|
79
|
+
address[] memory targets,
|
|
80
|
+
uint256[] memory values,
|
|
81
|
+
bytes[] memory calldatas,
|
|
82
|
+
bytes32 descriptionHash
|
|
83
|
+
) internal virtual override returns (uint48) {
|
|
84
|
+
uint256 delay = _timelock.getMinDelay();
|
|
85
|
+
|
|
86
|
+
bytes32 salt = _timelockSalt(descriptionHash);
|
|
87
|
+
_timelockIds[proposalId] = _timelock.hashOperationBatch(targets, values, calldatas, 0, salt);
|
|
88
|
+
_timelock.scheduleBatch(targets, values, calldatas, 0, salt, delay);
|
|
89
|
+
|
|
90
|
+
return SafeCast.toUint48(block.timestamp + delay);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @dev Overridden version of the {Governor-_executeOperations} function that runs the already queued proposal
|
|
95
|
+
* through the timelock.
|
|
96
|
+
*/
|
|
97
|
+
function _executeOperations(
|
|
98
|
+
uint256 proposalId,
|
|
99
|
+
address[] memory targets,
|
|
100
|
+
uint256[] memory values,
|
|
101
|
+
bytes[] memory calldatas,
|
|
102
|
+
bytes32 descriptionHash
|
|
103
|
+
) internal virtual override {
|
|
104
|
+
// execute
|
|
105
|
+
_timelock.executeBatch{value: msg.value}(targets, values, calldatas, 0, _timelockSalt(descriptionHash));
|
|
106
|
+
// cleanup for refund
|
|
107
|
+
delete _timelockIds[proposalId];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @dev Overridden version of the {Governor-_cancel} function to cancel the timelocked proposal if it has already
|
|
112
|
+
* been queued.
|
|
113
|
+
*/
|
|
114
|
+
// This function can reenter through the external call to the timelock, but we assume the timelock is trusted and
|
|
115
|
+
// well behaved (according to TimelockController) and this will not happen.
|
|
116
|
+
// slither-disable-next-line reentrancy-no-eth
|
|
117
|
+
function _cancel(
|
|
118
|
+
address[] memory targets,
|
|
119
|
+
uint256[] memory values,
|
|
120
|
+
bytes[] memory calldatas,
|
|
121
|
+
bytes32 descriptionHash
|
|
122
|
+
) internal virtual override returns (uint256) {
|
|
123
|
+
uint256 proposalId = super._cancel(targets, values, calldatas, descriptionHash);
|
|
124
|
+
|
|
125
|
+
bytes32 timelockId = _timelockIds[proposalId];
|
|
126
|
+
if (timelockId != 0) {
|
|
127
|
+
// cancel
|
|
128
|
+
_timelock.cancel(timelockId);
|
|
129
|
+
// cleanup
|
|
130
|
+
delete _timelockIds[proposalId];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return proposalId;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @dev Address through which the governor executes action. In this case, the timelock.
|
|
138
|
+
*/
|
|
139
|
+
function _executor() internal view virtual override returns (address) {
|
|
140
|
+
return address(_timelock);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @dev Public endpoint to update the underlying timelock instance. Restricted to the timelock itself, so updates
|
|
145
|
+
* must be proposed, scheduled, and executed through governance proposals.
|
|
146
|
+
*
|
|
147
|
+
* CAUTION: It is not recommended to change the timelock while there are other queued governance proposals.
|
|
148
|
+
*/
|
|
149
|
+
function updateTimelock(TimelockController newTimelock) public virtual onlyGovernance {
|
|
150
|
+
_updateTimelock(newTimelock);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function _updateTimelock(TimelockController newTimelock) private {
|
|
154
|
+
emit TimelockChange(address(_timelock), address(newTimelock));
|
|
155
|
+
_timelock = newTimelock;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @dev Computes the {TimelockController} operation salt.
|
|
160
|
+
*
|
|
161
|
+
* It is computed with the governor address itself to avoid collisions across governor instances using the
|
|
162
|
+
* same timelock.
|
|
163
|
+
*/
|
|
164
|
+
function _timelockSalt(bytes32 descriptionHash) private view returns (bytes32) {
|
|
165
|
+
return bytes20(address(this)) ^ descriptionHash;
|
|
166
|
+
}
|
|
167
|
+
}
|