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,376 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v5.8.0) (metatx/ERC2771Forwarder.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.24;
|
|
5
|
+
|
|
6
|
+
import {Address} from "../utils/Address.sol";
|
|
7
|
+
import {ECDSA} from "../utils/cryptography/ECDSA.sol";
|
|
8
|
+
import {EIP712} from "../utils/cryptography/EIP712.sol";
|
|
9
|
+
import {Errors} from "../utils/Errors.sol";
|
|
10
|
+
import {Nonces} from "../utils/Nonces.sol";
|
|
11
|
+
import {ERC2771Context} from "./ERC2771Context.sol";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @dev A forwarder compatible with ERC-2771 contracts. See {ERC2771Context}.
|
|
15
|
+
*
|
|
16
|
+
* This forwarder operates on forward requests that include:
|
|
17
|
+
*
|
|
18
|
+
* * `from`: An address to operate on behalf of. It is required to be equal to the request signer.
|
|
19
|
+
* * `to`: The address that should be called.
|
|
20
|
+
* * `value`: The amount of native token to attach with the requested call.
|
|
21
|
+
* * `gas`: The amount of gas limit that will be forwarded with the requested call.
|
|
22
|
+
* * `nonce` (implicit): Taken from {Nonces} for `from` and included in the signed typed data.
|
|
23
|
+
* * `deadline`: A timestamp after which the request is not executable anymore.
|
|
24
|
+
* * `data`: Encoded `msg.data` to send with the requested call.
|
|
25
|
+
*
|
|
26
|
+
* Relayers are able to submit batches if they are processing a high volume of requests. With high
|
|
27
|
+
* throughput, relayers may run into limitations of the chain such as limits on the number of
|
|
28
|
+
* transactions in the mempool. In these cases the recommendation is to distribute the load among
|
|
29
|
+
* multiple accounts.
|
|
30
|
+
*
|
|
31
|
+
* NOTE: Batching requests includes an optional refund for unused `msg.value` that is achieved by
|
|
32
|
+
* performing a call with empty calldata. While this is within the bounds of ERC-2771 compliance,
|
|
33
|
+
* if the refund receiver happens to consider the forwarder a trusted forwarder, it MUST properly
|
|
34
|
+
* handle `msg.data.length == 0`. `ERC2771Context` in OpenZeppelin Contracts versions prior to 4.9.3
|
|
35
|
+
* do not handle this properly.
|
|
36
|
+
*
|
|
37
|
+
* ==== Security Considerations
|
|
38
|
+
*
|
|
39
|
+
* If a relayer submits a forward request, it should be willing to pay up to 100% of the gas amount
|
|
40
|
+
* specified in the request. This contract does not implement any kind of retribution for this gas,
|
|
41
|
+
* and it is assumed that there is an out of band incentive for relayers to pay for execution on
|
|
42
|
+
* behalf of signers. Often, the relayer is operated by a project that will consider it a user
|
|
43
|
+
* acquisition cost.
|
|
44
|
+
*
|
|
45
|
+
* By offering to pay for gas, relayers are at risk of having that gas used by an attacker toward
|
|
46
|
+
* some other purpose that is not aligned with the expected out of band incentives. If you operate a
|
|
47
|
+
* relayer, consider whitelisting target contracts and function selectors. When relaying ERC-721 or
|
|
48
|
+
* ERC-1155 transfers specifically, consider rejecting the use of the `data` field, since it can be
|
|
49
|
+
* used to execute arbitrary code.
|
|
50
|
+
*/
|
|
51
|
+
contract ERC2771Forwarder is EIP712, Nonces {
|
|
52
|
+
using ECDSA for bytes32;
|
|
53
|
+
|
|
54
|
+
struct ForwardRequestData {
|
|
55
|
+
address from;
|
|
56
|
+
address to;
|
|
57
|
+
uint256 value;
|
|
58
|
+
uint256 gas;
|
|
59
|
+
uint48 deadline;
|
|
60
|
+
bytes data;
|
|
61
|
+
bytes signature;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bytes32 internal constant FORWARD_REQUEST_TYPEHASH =
|
|
65
|
+
keccak256(
|
|
66
|
+
"ForwardRequest(address from,address to,uint256 value,uint256 gas,uint256 nonce,uint48 deadline,bytes data)"
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @dev Emitted when a `ForwardRequest` is executed.
|
|
71
|
+
*
|
|
72
|
+
* NOTE: An unsuccessful forward request could be due to an invalid signature, an expired deadline,
|
|
73
|
+
* or simply a revert in the requested call. The contract guarantees that the relayer is not able to force
|
|
74
|
+
* the requested call to run out of gas.
|
|
75
|
+
*/
|
|
76
|
+
event ExecutedForwardRequest(address indexed signer, uint256 nonce, bool success);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @dev A request in the batch failed and no `refundReceiver` was set to handle the leftover value.
|
|
80
|
+
*/
|
|
81
|
+
error ERC2771ForwarderNoRefundReceiver();
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @dev The request `from` doesn't match with the recovered `signer`.
|
|
85
|
+
*/
|
|
86
|
+
error ERC2771ForwarderInvalidSigner(address signer, address from);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @dev The `requestedValue` doesn't match with the available `msgValue`.
|
|
90
|
+
*/
|
|
91
|
+
error ERC2771ForwarderMismatchedValue(uint256 requestedValue, uint256 msgValue);
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @dev The request `deadline` has expired.
|
|
95
|
+
*/
|
|
96
|
+
error ERC2771ForwarderExpiredRequest(uint48 deadline);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @dev The request target doesn't trust the `forwarder`.
|
|
100
|
+
*/
|
|
101
|
+
error ERC2771UntrustfulTarget(address target, address forwarder);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @dev See {EIP712-constructor}.
|
|
105
|
+
*/
|
|
106
|
+
constructor(string memory name) EIP712(name, "1") {}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @dev Returns `true` if a request is valid for a provided `signature` at the current block timestamp.
|
|
110
|
+
*
|
|
111
|
+
* A transaction is considered valid when the target trusts this forwarder, the request hasn't expired
|
|
112
|
+
* (deadline is not met), and the signer matches the `from` parameter of the signed request.
|
|
113
|
+
*
|
|
114
|
+
* NOTE: A request may return false here but it won't cause {executeBatch} to revert if a refund
|
|
115
|
+
* receiver is provided.
|
|
116
|
+
*/
|
|
117
|
+
function verify(ForwardRequestData calldata request) public view virtual returns (bool) {
|
|
118
|
+
(bool isTrustedForwarder, bool active, bool signerMatch, ) = _validate(request);
|
|
119
|
+
return isTrustedForwarder && active && signerMatch;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @dev Executes a `request` on behalf of `signature`'s signer using the ERC-2771 protocol. The gas
|
|
124
|
+
* provided to the requested call may not be exactly the amount requested, but the call will not run
|
|
125
|
+
* out of gas. Will revert if the request is invalid or the call reverts, in this case the nonce is not consumed.
|
|
126
|
+
*
|
|
127
|
+
* Requirements:
|
|
128
|
+
*
|
|
129
|
+
* - The request value should be equal to the provided `msg.value`.
|
|
130
|
+
* - The request should be valid according to {verify}.
|
|
131
|
+
*/
|
|
132
|
+
function execute(ForwardRequestData calldata request) public payable virtual {
|
|
133
|
+
// We make sure that msg.value and request.value match exactly.
|
|
134
|
+
// If the request is invalid or the call reverts, this whole function
|
|
135
|
+
// will revert, ensuring value isn't stuck.
|
|
136
|
+
if (msg.value != request.value) {
|
|
137
|
+
revert ERC2771ForwarderMismatchedValue(request.value, msg.value);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!_execute(request, true)) {
|
|
141
|
+
revert Errors.FailedCall();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @dev Batch version of {execute} with optional refunding.
|
|
147
|
+
*
|
|
148
|
+
* In case a batch contains at least one invalid request (see {verify}), the
|
|
149
|
+
* request will be skipped and the `refundReceiver` parameter will receive back the
|
|
150
|
+
* unused requested value at the end of the execution. This is done to prevent reverting
|
|
151
|
+
* the entire batch when a request is invalid or has already been submitted.
|
|
152
|
+
*
|
|
153
|
+
* If the `refundReceiver` is `address(0)`, the function will revert
|
|
154
|
+
* when any request is invalid or when a valid request's forwarded call fails while
|
|
155
|
+
* carrying value (since there is no receiver to refund the leftover ETH to).
|
|
156
|
+
*
|
|
157
|
+
* Requirements:
|
|
158
|
+
*
|
|
159
|
+
* - The sum of the requests' values should be equal to the provided `msg.value`.
|
|
160
|
+
* - All of the requests should be valid (see {verify}) when `refundReceiver` is the zero address.
|
|
161
|
+
*
|
|
162
|
+
* NOTE: Setting a zero `refundReceiver` reverts the whole batch if any request is invalid or a value-bearing
|
|
163
|
+
* call fails, so it should only be used when transaction inclusion is under the caller's control.
|
|
164
|
+
*/
|
|
165
|
+
function executeBatch(
|
|
166
|
+
ForwardRequestData[] calldata requests,
|
|
167
|
+
address payable refundReceiver
|
|
168
|
+
) public payable virtual {
|
|
169
|
+
bool requireValidRequests = refundReceiver == address(0);
|
|
170
|
+
|
|
171
|
+
uint256 requestsValue;
|
|
172
|
+
uint256 refundValue;
|
|
173
|
+
|
|
174
|
+
for (uint256 i; i < requests.length; ++i) {
|
|
175
|
+
requestsValue += requests[i].value;
|
|
176
|
+
bool success = _execute(requests[i], requireValidRequests);
|
|
177
|
+
if (!success) {
|
|
178
|
+
refundValue += requests[i].value;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// The batch should revert if there's a mismatched msg.value provided
|
|
183
|
+
// to avoid request value tampering
|
|
184
|
+
if (requestsValue != msg.value) {
|
|
185
|
+
revert ERC2771ForwarderMismatchedValue(requestsValue, msg.value);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Some requests with value were invalid (possibly due to frontrunning).
|
|
189
|
+
// To avoid leaving ETH in the contract, this value is refunded.
|
|
190
|
+
if (refundValue != 0) {
|
|
191
|
+
if (requireValidRequests) revert ERC2771ForwarderNoRefundReceiver();
|
|
192
|
+
|
|
193
|
+
// We know refundReceiver != address(0) && requestsValue == msg.value
|
|
194
|
+
// meaning we can ensure refundValue is not taken from the original contract's balance
|
|
195
|
+
// and refundReceiver is a known account.
|
|
196
|
+
Address.sendValue(refundReceiver, refundValue);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @dev Validates if the provided request can be executed at current block timestamp with
|
|
202
|
+
* the given `request.signature` on behalf of `request.from`.
|
|
203
|
+
*/
|
|
204
|
+
function _validate(
|
|
205
|
+
ForwardRequestData calldata request
|
|
206
|
+
) internal view virtual returns (bool isTrustedForwarder, bool active, bool signerMatch, address signer) {
|
|
207
|
+
(bool isValid, address recovered) = _recoverForwardRequestSigner(request);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
_isTrustedByTarget(request.to),
|
|
211
|
+
request.deadline >= block.timestamp,
|
|
212
|
+
isValid && recovered == request.from,
|
|
213
|
+
recovered
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @dev Returns a tuple with the recovered the signer of an EIP712 forward request message hash
|
|
219
|
+
* and a boolean indicating if the signature is valid.
|
|
220
|
+
*
|
|
221
|
+
* NOTE: The signature is considered valid if {ECDSA-tryRecoverCalldata} indicates no recover error for it.
|
|
222
|
+
*/
|
|
223
|
+
function _recoverForwardRequestSigner(
|
|
224
|
+
ForwardRequestData calldata request
|
|
225
|
+
) internal view virtual returns (bool isValid, address signer) {
|
|
226
|
+
(address recovered, ECDSA.RecoverError err, ) = _hashTypedDataV4(
|
|
227
|
+
keccak256(
|
|
228
|
+
abi.encode(
|
|
229
|
+
FORWARD_REQUEST_TYPEHASH,
|
|
230
|
+
request.from,
|
|
231
|
+
request.to,
|
|
232
|
+
request.value,
|
|
233
|
+
request.gas,
|
|
234
|
+
nonces(request.from),
|
|
235
|
+
request.deadline,
|
|
236
|
+
keccak256(request.data)
|
|
237
|
+
)
|
|
238
|
+
)
|
|
239
|
+
).tryRecoverCalldata(request.signature);
|
|
240
|
+
|
|
241
|
+
return (err == ECDSA.RecoverError.NoError, recovered);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @dev Validates and executes a signed request returning the request call `success` value.
|
|
246
|
+
*
|
|
247
|
+
* Internal function without msg.value validation.
|
|
248
|
+
*
|
|
249
|
+
* Requirements:
|
|
250
|
+
*
|
|
251
|
+
* - The caller must have provided enough gas to forward with the call.
|
|
252
|
+
* - The request must be valid (see {verify}) if the `requireValidRequest` is true.
|
|
253
|
+
*
|
|
254
|
+
* Emits an {ExecutedForwardRequest} event.
|
|
255
|
+
*
|
|
256
|
+
* IMPORTANT: Using this function doesn't check that all the `msg.value` was sent, potentially
|
|
257
|
+
* leaving value stuck in the contract.
|
|
258
|
+
*/
|
|
259
|
+
function _execute(
|
|
260
|
+
ForwardRequestData calldata request,
|
|
261
|
+
bool requireValidRequest
|
|
262
|
+
) internal virtual returns (bool success) {
|
|
263
|
+
(bool isTrustedForwarder, bool active, bool signerMatch, address signer) = _validate(request);
|
|
264
|
+
|
|
265
|
+
// Need to explicitly specify if a revert is required since non-reverting is default for
|
|
266
|
+
// batches and reversion is opt-in since it could be useful in some scenarios
|
|
267
|
+
if (requireValidRequest) {
|
|
268
|
+
if (!isTrustedForwarder) {
|
|
269
|
+
revert ERC2771UntrustfulTarget(request.to, address(this));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (!active) {
|
|
273
|
+
revert ERC2771ForwarderExpiredRequest(request.deadline);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (!signerMatch) {
|
|
277
|
+
revert ERC2771ForwarderInvalidSigner(signer, request.from);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Ignore an invalid request because requireValidRequest = false
|
|
282
|
+
if (isTrustedForwarder && signerMatch && active) {
|
|
283
|
+
// Nonce should be used before the call to prevent reusing by reentrancy
|
|
284
|
+
uint256 currentNonce = _useNonce(signer);
|
|
285
|
+
|
|
286
|
+
uint256 reqGas = request.gas;
|
|
287
|
+
address to = request.to;
|
|
288
|
+
uint256 value = request.value;
|
|
289
|
+
bytes memory data = abi.encodePacked(request.data, request.from);
|
|
290
|
+
|
|
291
|
+
uint256 gasLeft;
|
|
292
|
+
|
|
293
|
+
assembly ("memory-safe") {
|
|
294
|
+
success := call(reqGas, to, value, add(data, 0x20), mload(data), 0x00, 0x00)
|
|
295
|
+
gasLeft := gas()
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
_checkForwardedGas(gasLeft, request);
|
|
299
|
+
|
|
300
|
+
emit ExecutedForwardRequest(signer, currentNonce, success);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @dev Returns whether the target trusts this forwarder.
|
|
306
|
+
*
|
|
307
|
+
* This function performs a static call to the target contract calling the
|
|
308
|
+
* {ERC2771Context-isTrustedForwarder} function.
|
|
309
|
+
*
|
|
310
|
+
* NOTE: Consider the execution of this forwarder is permissionless. Without this check, anyone may transfer assets
|
|
311
|
+
* that are owned by, or are approved to this forwarder.
|
|
312
|
+
*/
|
|
313
|
+
function _isTrustedByTarget(address target) internal view virtual returns (bool) {
|
|
314
|
+
bytes memory encodedParams = abi.encodeCall(ERC2771Context.isTrustedForwarder, (address(this)));
|
|
315
|
+
|
|
316
|
+
bool success;
|
|
317
|
+
uint256 returnSize;
|
|
318
|
+
uint256 returnValue;
|
|
319
|
+
assembly ("memory-safe") {
|
|
320
|
+
// Perform the staticcall and save the result in the scratch space.
|
|
321
|
+
// | Location | Content | Content (Hex) |
|
|
322
|
+
// |-----------|----------|--------------------------------------------------------------------|
|
|
323
|
+
// | | | result ↓ |
|
|
324
|
+
// | 0x00:0x1F | selector | 0x0000000000000000000000000000000000000000000000000000000000000001 |
|
|
325
|
+
success := staticcall(gas(), target, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
|
|
326
|
+
returnSize := returndatasize()
|
|
327
|
+
returnValue := mload(0x00)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return success && returnSize >= 0x20 && returnValue > 0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @dev Checks if the requested gas was correctly forwarded to the callee.
|
|
335
|
+
*
|
|
336
|
+
* As a consequence of https://eips.ethereum.org/EIPS/eip-150[EIP-150]:
|
|
337
|
+
* - At most `gasleft() - floor(gasleft() / 64)` is forwarded to the callee.
|
|
338
|
+
* - At least `floor(gasleft() / 64)` is kept in the caller.
|
|
339
|
+
*
|
|
340
|
+
* It reverts consuming all the available gas if the forwarded gas is not the requested gas.
|
|
341
|
+
*
|
|
342
|
+
* IMPORTANT: The `gasLeft` parameter should be measured exactly at the end of the forwarded call.
|
|
343
|
+
* Any gas consumed in between will make room for bypassing this check.
|
|
344
|
+
*/
|
|
345
|
+
function _checkForwardedGas(uint256 gasLeft, ForwardRequestData calldata request) private pure {
|
|
346
|
+
// To avoid insufficient gas griefing attacks, as referenced in https://ronan.eth.limo/blog/ethereum-gas-dangers/
|
|
347
|
+
//
|
|
348
|
+
// A malicious relayer can attempt to shrink the gas forwarded so that the underlying call reverts out-of-gas
|
|
349
|
+
// but the forwarding itself still succeeds. In order to make sure that the subcall received sufficient gas,
|
|
350
|
+
// we will inspect gasleft() after the forwarding.
|
|
351
|
+
//
|
|
352
|
+
// Let X be the gas available before the subcall, such that the subcall gets at most X * 63 / 64.
|
|
353
|
+
// We can't know X after CALL dynamic costs, but we want it to be such that X * 63 / 64 >= req.gas.
|
|
354
|
+
// Let Y be the gas used in the subcall. gasleft() measured immediately after the subcall will be gasleft() = X - Y.
|
|
355
|
+
// If the subcall ran out of gas, then Y = X * 63 / 64 and gasleft() = X - Y = X / 64.
|
|
356
|
+
// Under this assumption req.gas / 63 > gasleft() is true if and only if
|
|
357
|
+
// req.gas / 63 > X / 64, or equivalently req.gas > X * 63 / 64.
|
|
358
|
+
// This means that if the subcall runs out of gas we are able to detect that insufficient gas was passed.
|
|
359
|
+
//
|
|
360
|
+
// We will now also see that req.gas / 63 > gasleft() implies that req.gas >= X * 63 / 64.
|
|
361
|
+
// The contract guarantees Y <= req.gas, thus gasleft() = X - Y >= X - req.gas.
|
|
362
|
+
// - req.gas / 63 > gasleft()
|
|
363
|
+
// - req.gas / 63 >= X - req.gas
|
|
364
|
+
// - req.gas >= X * 63 / 64
|
|
365
|
+
// In other words if req.gas < X * 63 / 64 then req.gas / 63 <= gasleft(), thus if the relayer behaves honestly
|
|
366
|
+
// the forwarding does not revert.
|
|
367
|
+
if (gasLeft < request.gas / 63) {
|
|
368
|
+
// We explicitly trigger invalid opcode to consume all gas and bubble-up the effects, since
|
|
369
|
+
// neither revert or assert consume all gas since Solidity 0.8.20
|
|
370
|
+
// https://docs.soliditylang.org/en/v0.8.20/control-structures.html#panic-via-assert-and-error-via-require
|
|
371
|
+
assembly ("memory-safe") {
|
|
372
|
+
invalid()
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arr00-testing-oz-contracts",
|
|
3
|
-
"
|
|
3
|
+
"description": "Secure Smart Contract library for Solidity",
|
|
4
|
+
"version": "5.8.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"**/*.sol",
|
|
7
|
+
"/build/contracts/*.json",
|
|
8
|
+
"!/mocks/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepack": "bash ../scripts/prepack.sh",
|
|
12
|
+
"prepare-docs": "cd ..; npm run prepare-docs"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/arr00/openzeppelin-contracts.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"solidity",
|
|
20
|
+
"ethereum",
|
|
21
|
+
"smart",
|
|
22
|
+
"contracts",
|
|
23
|
+
"security",
|
|
24
|
+
"zeppelin"
|
|
25
|
+
],
|
|
26
|
+
"author": "OpenZeppelin Community <maintainers@openzeppelin.org>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/arr00/openzeppelin-contracts/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://openzeppelin.com/contracts/"
|
|
4
32
|
}
|