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,170 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v5.8.0) (account/paymaster/Paymaster.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.20;
|
|
5
|
+
|
|
6
|
+
import {IEntryPoint, IPaymaster, PackedUserOperation} from "../../interfaces/IERC4337.sol";
|
|
7
|
+
import {ERC4337Utils} from "../utils/ERC4337Utils.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @dev A simple ERC4337 paymaster implementation. This base implementation only includes the minimal logic to validate
|
|
11
|
+
* and pay for user operations.
|
|
12
|
+
*
|
|
13
|
+
* Developers must implement the {Paymaster-_validatePaymasterUserOp} function to define the paymaster's validation
|
|
14
|
+
* and payment logic, and {Paymaster-_postOp} function to define the post-operation logic. The `context` parameter
|
|
15
|
+
* is used to pass data between the validation and post execution phases.
|
|
16
|
+
*
|
|
17
|
+
* The paymaster includes support to call the {IEntryPointStake} interface to manage the paymaster's deposits and stakes
|
|
18
|
+
* through the internal functions {_deposit}, {_withdraw}, {_addStake}, {_unlockStake} and {_withdrawStake}.
|
|
19
|
+
*
|
|
20
|
+
* * Deposits are used to pay for user operations.
|
|
21
|
+
* * Stakes are used to guarantee the paymaster's reputation and obtain more flexibility in accessing storage.
|
|
22
|
+
*
|
|
23
|
+
* [IMPORTANT]
|
|
24
|
+
* ====
|
|
25
|
+
* The deposit and stake functions are `internal` so that developers can expose them under the public interface and
|
|
26
|
+
* authorization mechanism of their choice. Public versions of {_withdraw}, {_unlockStake} and {_withdrawStake} MUST
|
|
27
|
+
* be exposed and properly authorized, otherwise the deposit and stake will be permanently locked.
|
|
28
|
+
*
|
|
29
|
+
* Example implementation exposing the deposit and stake functions using {AccessControl}:
|
|
30
|
+
*
|
|
31
|
+
* ```solidity
|
|
32
|
+
* contract MyPaymaster is Paymaster, AccessControl {
|
|
33
|
+
* bytes32 private constant WITHDRAWER_ROLE = keccak256("WITHDRAWER_ROLE");
|
|
34
|
+
* bytes32 private constant UNSTAKER_ROLE = keccak256("UNSTAKER_ROLE");
|
|
35
|
+
*
|
|
36
|
+
* constructor() {
|
|
37
|
+
* _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* function deposit() public payable virtual {
|
|
41
|
+
* _deposit(msg.value);
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* function withdraw(address payable to, uint256 value) public virtual onlyRole(WITHDRAWER_ROLE) {
|
|
45
|
+
* _withdraw(to, value);
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* function addStake(uint32 unstakeDelaySec) public payable virtual {
|
|
49
|
+
* _addStake(msg.value, unstakeDelaySec);
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* function unlockStake() public virtual onlyRole(UNSTAKER_ROLE) {
|
|
53
|
+
* _unlockStake();
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* function withdrawStake(address payable to) public virtual onlyRole(UNSTAKER_ROLE) {
|
|
57
|
+
* _withdrawStake(to);
|
|
58
|
+
* }
|
|
59
|
+
*
|
|
60
|
+
* function _validatePaymasterUserOp(
|
|
61
|
+
* PackedUserOperation calldata userOp,
|
|
62
|
+
* bytes32 userOpHash,
|
|
63
|
+
* uint256 requiredPreFund
|
|
64
|
+
* ) internal virtual override returns (bytes memory context, uint256 validationData) {
|
|
65
|
+
* // validation logic
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
* ====
|
|
70
|
+
*
|
|
71
|
+
* NOTE: See [Paymaster's unstaked reputation rules](https://eips.ethereum.org/EIPS/eip-7562#unstaked-paymasters-reputation-rules)
|
|
72
|
+
* for more details on the paymaster's storage access limitations.
|
|
73
|
+
*/
|
|
74
|
+
abstract contract Paymaster is IPaymaster {
|
|
75
|
+
/// @dev Unauthorized call to the paymaster.
|
|
76
|
+
error PaymasterUnauthorized(address sender);
|
|
77
|
+
|
|
78
|
+
/// @dev Revert if the caller is not the entry point.
|
|
79
|
+
modifier onlyEntryPoint() {
|
|
80
|
+
_checkEntryPoint();
|
|
81
|
+
_;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// @dev Canonical entry point for the account that forwards and validates user operations.
|
|
85
|
+
function entryPoint() public view virtual returns (IEntryPoint) {
|
|
86
|
+
return ERC4337Utils.ENTRYPOINT_V09;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// @inheritdoc IPaymaster
|
|
90
|
+
function validatePaymasterUserOp(
|
|
91
|
+
PackedUserOperation calldata userOp,
|
|
92
|
+
bytes32 userOpHash,
|
|
93
|
+
uint256 maxCost
|
|
94
|
+
) public virtual onlyEntryPoint returns (bytes memory context, uint256 validationData) {
|
|
95
|
+
return _validatePaymasterUserOp(userOp, userOpHash, maxCost);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// @inheritdoc IPaymaster
|
|
99
|
+
function postOp(
|
|
100
|
+
PostOpMode mode,
|
|
101
|
+
bytes calldata context,
|
|
102
|
+
uint256 actualGasCost,
|
|
103
|
+
uint256 actualUserOpFeePerGas
|
|
104
|
+
) public virtual onlyEntryPoint {
|
|
105
|
+
_postOp(mode, context, actualGasCost, actualUserOpFeePerGas);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @dev Internal validation of whether the paymaster is willing to pay for the user operation.
|
|
110
|
+
* Returns the context to be passed to postOp and the validation data.
|
|
111
|
+
*
|
|
112
|
+
* The `requiredPreFund` is the amount the paymaster has to pay (in native tokens). It's calculated
|
|
113
|
+
* as `requiredGas * userOp.maxFeePerGas`, where `required` gas can be calculated from the user operation
|
|
114
|
+
* as `verificationGasLimit + callGasLimit + paymasterVerificationGasLimit + paymasterPostOpGasLimit + preVerificationGas`
|
|
115
|
+
*/
|
|
116
|
+
function _validatePaymasterUserOp(
|
|
117
|
+
PackedUserOperation calldata userOp,
|
|
118
|
+
bytes32 userOpHash,
|
|
119
|
+
uint256 requiredPreFund
|
|
120
|
+
) internal virtual returns (bytes memory context, uint256 validationData);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @dev Handles post user operation execution logic. The caller must be the entry point.
|
|
124
|
+
*
|
|
125
|
+
* It receives the `context` returned by `_validatePaymasterUserOp`. Function is not called if no context
|
|
126
|
+
* is returned by {validatePaymasterUserOp}.
|
|
127
|
+
*
|
|
128
|
+
* NOTE: The `actualUserOpFeePerGas` is not `tx.gasprice`. A user operation can be bundled with other transactions
|
|
129
|
+
* making the gas price of the user operation to differ.
|
|
130
|
+
*/
|
|
131
|
+
function _postOp(
|
|
132
|
+
PostOpMode /* mode */,
|
|
133
|
+
bytes calldata /* context */,
|
|
134
|
+
uint256 /* actualGasCost */,
|
|
135
|
+
uint256 /* actualUserOpFeePerGas */
|
|
136
|
+
) internal virtual {}
|
|
137
|
+
|
|
138
|
+
/// @dev Ensures the caller is the {entrypoint}.
|
|
139
|
+
function _checkEntryPoint() internal view virtual {
|
|
140
|
+
address sender = msg.sender;
|
|
141
|
+
if (sender != address(entryPoint())) {
|
|
142
|
+
revert PaymasterUnauthorized(sender);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/// @dev Calls {IEntryPointStake-depositTo}.
|
|
147
|
+
function _deposit(uint256 value) internal virtual {
|
|
148
|
+
entryPoint().depositTo{value: value}(address(this));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// @dev Calls {IEntryPointStake-withdrawTo}.
|
|
152
|
+
function _withdraw(address payable to, uint256 value) internal virtual {
|
|
153
|
+
entryPoint().withdrawTo(to, value);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/// @dev Calls {IEntryPointStake-addStake}.
|
|
157
|
+
function _addStake(uint256 value, uint32 unstakeDelaySec) internal virtual {
|
|
158
|
+
entryPoint().addStake{value: value}(unstakeDelaySec);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// @dev Calls {IEntryPointStake-unlockStake}.
|
|
162
|
+
function _unlockStake() internal virtual {
|
|
163
|
+
entryPoint().unlockStake();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// @dev Calls {IEntryPointStake-withdrawStake}.
|
|
167
|
+
function _withdrawStake(address payable to) internal virtual {
|
|
168
|
+
entryPoint().withdrawStake(to);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// OpenZeppelin Contracts (last updated v5.8.0) (account/paymaster/extensions/PaymasterERC20.sol)
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.20;
|
|
5
|
+
|
|
6
|
+
import {IERC20, SafeERC20} from "../../../token/ERC20/utils/SafeERC20.sol";
|
|
7
|
+
import {Math} from "../../../utils/math/Math.sol";
|
|
8
|
+
import {SafeCast} from "../../../utils/math/SafeCast.sol";
|
|
9
|
+
import {ERC4337Utils, PackedUserOperation} from "../../utils/ERC4337Utils.sol";
|
|
10
|
+
import {Paymaster} from "../Paymaster.sol";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @dev Extension of {Paymaster} that enables users to pay gas with ERC-20 tokens.
|
|
14
|
+
*
|
|
15
|
+
* To enable this feature, developers must implement the {_fetchDetails} function:
|
|
16
|
+
*
|
|
17
|
+
* ```solidity
|
|
18
|
+
* function _fetchDetails(
|
|
19
|
+
* PackedUserOperation calldata userOp,
|
|
20
|
+
* bytes32 userOpHash
|
|
21
|
+
* ) internal view override returns (uint256 validationData, IERC20 token, uint256 tokenPerNative) {
|
|
22
|
+
* // Implement logic to fetch the token, and token price from the userOp
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The contract follows a pre-charge and refund model:
|
|
27
|
+
* 1. During validation, it pre-charges the maximum possible gas cost
|
|
28
|
+
* 2. After execution, it refunds any unused gas back to the user
|
|
29
|
+
*
|
|
30
|
+
* NOTE: {_prefund} performs a `transferFrom` during the validation phase, writing to the token contract's storage.
|
|
31
|
+
* ERC-7562 restricts unstaked paymasters from such accesses, and public mempool bundlers will reject these operations.
|
|
32
|
+
* Stake the paymaster (see {Paymaster-_addStake}) when deploying against a public mempool.
|
|
33
|
+
*
|
|
34
|
+
* [IMPORTANT]
|
|
35
|
+
* ====
|
|
36
|
+
* The {_withdrawTokens} function is `internal` so that developers can expose it under the public interface and
|
|
37
|
+
* authorization mechanism of their choice. Public versions of {_withdrawTokens} MUST be exposed and properly authorized,
|
|
38
|
+
* otherwise the tokens will be permanently stuck in the paymaster.
|
|
39
|
+
*
|
|
40
|
+
* Example implementation exposing the {_withdrawTokens} function using {AccessControl}:
|
|
41
|
+
*
|
|
42
|
+
* ```solidity
|
|
43
|
+
* contract MyPaymaster is Paymaster, AccessControl {
|
|
44
|
+
* bytes32 private constant WITHDRAWER_ROLE = keccak256("WITHDRAWER_ROLE");
|
|
45
|
+
*
|
|
46
|
+
* constructor() {
|
|
47
|
+
* _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* function withdrawTokens(IERC20 token, address recipient, uint256 amount) public virtual onlyRole(WITHDRAWER_ROLE) {
|
|
51
|
+
* _withdrawTokens(token, recipient, amount);
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* ...
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
* ====
|
|
58
|
+
*/
|
|
59
|
+
abstract contract PaymasterERC20 is Paymaster {
|
|
60
|
+
using ERC4337Utils for *;
|
|
61
|
+
using Math for *;
|
|
62
|
+
using SafeCast for *;
|
|
63
|
+
using SafeERC20 for IERC20;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @dev Emitted when a user operation identified by `userOpHash` is sponsored by this paymaster
|
|
67
|
+
* using the specified ERC-20 `token`. The `tokenAmount` is the amount charged for the operation,
|
|
68
|
+
* and `tokenPerNative` is the valuation of the token in units of token per native currency (e.g., ETH).
|
|
69
|
+
*/
|
|
70
|
+
event UserOperationSponsored(
|
|
71
|
+
bytes32 indexed userOpHash,
|
|
72
|
+
address indexed token,
|
|
73
|
+
uint256 tokenAmount,
|
|
74
|
+
uint256 tokenPerNative
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @dev Thrown when the paymaster fails to refund the difference between the `prefundAmount`
|
|
79
|
+
* and the `actualAmount` of `token`.
|
|
80
|
+
*/
|
|
81
|
+
error PaymasterERC20FailedRefund(IERC20 token, uint256 prefundAmount, uint256 actualAmount, bytes prefundContext);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @dev See {Paymaster-_validatePaymasterUserOp}.
|
|
85
|
+
*
|
|
86
|
+
* Attempts to retrieve the `token` and `tokenPerNative` from the user operation (see {_fetchDetails})
|
|
87
|
+
* and prefund the user operation using these values and the `maxCost` argument (see {_prefund}).
|
|
88
|
+
*
|
|
89
|
+
* Returns `abi.encodePacked(userOpHash, token, tokenPerNative, prefundAmount, prefunder, penaltyGas, prefundContext)`
|
|
90
|
+
* in `context` if the prefund is successful. Otherwise, it returns empty bytes.
|
|
91
|
+
*/
|
|
92
|
+
function _validatePaymasterUserOp(
|
|
93
|
+
PackedUserOperation calldata userOp,
|
|
94
|
+
bytes32 userOpHash,
|
|
95
|
+
uint256 maxCost
|
|
96
|
+
) internal virtual override returns (bytes memory context, uint256 validationData) {
|
|
97
|
+
IERC20 token;
|
|
98
|
+
uint256 tokenPerNative;
|
|
99
|
+
address userOpSender = userOp.sender;
|
|
100
|
+
(validationData, token, tokenPerNative) = _fetchDetails(userOp, userOpHash);
|
|
101
|
+
|
|
102
|
+
if (uint160(validationData) == ERC4337Utils.SIG_VALIDATION_FAILED || tokenPerNative < _minTokensPerNative())
|
|
103
|
+
return (bytes(""), ERC4337Utils.SIG_VALIDATION_FAILED);
|
|
104
|
+
|
|
105
|
+
// Worst-case unused-gas penalty that the EntryPoint may debit from the paymaster's deposit for the
|
|
106
|
+
// user-controlled `paymasterPostOpGasLimit` (see {_postOpGasPenalty}). The EntryPoint computes this penalty
|
|
107
|
+
// only after `postOp` returns, so it is absent from the `actualGasCost` reported to {_postOp}. We price it
|
|
108
|
+
// into the charge here and retain it in {_postOp}, so a user cannot inflate `paymasterPostOpGasLimit` to
|
|
109
|
+
// drain the paymaster's deposit.
|
|
110
|
+
//
|
|
111
|
+
// Only the part of the limit above {_postOpGasBudget} can go unused: the paymaster bills the budget in full
|
|
112
|
+
// through {_postOpCost}, so charging a penalty on it would bill the sender twice for gas the paymaster
|
|
113
|
+
// itself demanded.
|
|
114
|
+
uint256 penaltyGas = _postOpGasPenalty(
|
|
115
|
+
userOp.paymasterPostOpGasLimit().saturatingSub(_postOpGasBudget(userOp))
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// If the _erc20Cost math fails, the returned value will be type(uint256).max, which we will never be able
|
|
119
|
+
// to charge as a prefund. The `trySafeTransferFrom` in the `_prefund` will fail, causing success to be false.
|
|
120
|
+
// Saturating arithmetic keeps an overflow in the native cost from wrapping: it saturates to
|
|
121
|
+
// `type(uint256).max`, which `_erc20Cost` also returns, and fails the prefund instead of undercharging.
|
|
122
|
+
//
|
|
123
|
+
// native cost is computed as: maxCost + ((_postOpCost() + penaltyGas) * userOp.maxFeePerGas())
|
|
124
|
+
uint256 maxTokenCost = _erc20Cost(
|
|
125
|
+
_postOpCost().saturatingAdd(penaltyGas).saturatingMul(userOp.maxFeePerGas()).saturatingAdd(maxCost),
|
|
126
|
+
tokenPerNative
|
|
127
|
+
);
|
|
128
|
+
(bool success, address prefunder, uint256 prefundAmount, bytes memory prefundContext) = _prefund(
|
|
129
|
+
userOp,
|
|
130
|
+
userOpHash,
|
|
131
|
+
token,
|
|
132
|
+
tokenPerNative,
|
|
133
|
+
userOpSender,
|
|
134
|
+
maxTokenCost
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
return
|
|
138
|
+
success
|
|
139
|
+
? (
|
|
140
|
+
abi.encodePacked(
|
|
141
|
+
userOpHash,
|
|
142
|
+
token,
|
|
143
|
+
tokenPerNative,
|
|
144
|
+
prefundAmount,
|
|
145
|
+
prefunder,
|
|
146
|
+
penaltyGas,
|
|
147
|
+
prefundContext
|
|
148
|
+
),
|
|
149
|
+
validationData
|
|
150
|
+
)
|
|
151
|
+
: (bytes(""), ERC4337Utils.SIG_VALIDATION_FAILED);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @dev Charges `prefundAmount` of `token` from `prefunder_` and returns the effective prefund actually pulled.
|
|
156
|
+
*
|
|
157
|
+
* The base implementation pulls exactly the requested `prefundAmount`. Extensions may inflate the amount
|
|
158
|
+
* (e.g. a guarantor adds the cost of the extra postOp work it performs) and must return the effective value.
|
|
159
|
+
*
|
|
160
|
+
* Returns `(success, prefunder, effectivePrefundAmount, prefundContext)`. `prefundContext` is forwarded to
|
|
161
|
+
* {_postOp} through its `context` argument and may be used by overrides to carry data into {_refund}.
|
|
162
|
+
*
|
|
163
|
+
* NOTE: Consider not reverting if the prefund fails when overriding this function. This is to avoid reverting
|
|
164
|
+
* during the validation phase of the user operation, which may penalize the paymaster's reputation according
|
|
165
|
+
* to ERC-7562 validation rules.
|
|
166
|
+
*/
|
|
167
|
+
function _prefund(
|
|
168
|
+
PackedUserOperation calldata /* userOp */,
|
|
169
|
+
bytes32 /* userOpHash */,
|
|
170
|
+
IERC20 token,
|
|
171
|
+
uint256 /* tokenPerNative */,
|
|
172
|
+
address prefunder_,
|
|
173
|
+
uint256 prefundAmount_
|
|
174
|
+
) internal virtual returns (bool success, address prefunder, uint256 prefundAmount, bytes memory prefundContext) {
|
|
175
|
+
return (token.trySafeTransferFrom(prefunder_, address(this), prefundAmount_), prefunder_, prefundAmount_, "");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @dev Attempts to refund the user operation after execution. See {_refund}.
|
|
180
|
+
*
|
|
181
|
+
* Reverts with {PaymasterERC20FailedRefund} if the refund fails.
|
|
182
|
+
*
|
|
183
|
+
* IMPORTANT: A revert here does not revert the whole bundle: the user operation is marked as failed and
|
|
184
|
+
* its execution rolled back, but the validation-phase prefund is not refunded. When a derived contract
|
|
185
|
+
* delegates the prefund to a third party (e.g. a guarantor), that party must consent to the sender-controlled
|
|
186
|
+
* `paymasterPostOpGasLimit` before authorizing, otherwise the sender can strand the third party's prefund by
|
|
187
|
+
* picking a limit below the actual postOp cost.
|
|
188
|
+
*/
|
|
189
|
+
function _postOp(
|
|
190
|
+
PostOpMode /* mode */,
|
|
191
|
+
bytes calldata context,
|
|
192
|
+
uint256 actualGasCost,
|
|
193
|
+
uint256 actualUserOpFeePerGas
|
|
194
|
+
) internal virtual override {
|
|
195
|
+
bytes32 userOpHash = bytes32(context[0x00:0x20]);
|
|
196
|
+
IERC20 token = IERC20(address(bytes20(context[0x20:0x34])));
|
|
197
|
+
uint256 tokenPerNative = uint256(bytes32(context[0x34:0x54]));
|
|
198
|
+
uint256 prefundAmount = uint256(bytes32(context[0x54:0x74]));
|
|
199
|
+
address prefunder = address(bytes20(context[0x74:0x88]));
|
|
200
|
+
uint256 penaltyGas = uint256(bytes32(context[0x88:0xA8]));
|
|
201
|
+
bytes calldata prefundContext = context[0xA8:];
|
|
202
|
+
|
|
203
|
+
// If the _erc20Cost math fails, the returned value will be type(uint256).max, which we will never be able
|
|
204
|
+
// to charge as a refund. The `trySafeTransfer` in the `_refund` will fail, causing success to be false.
|
|
205
|
+
// `penaltyGas` covers the EntryPoint's unused-gas penalty on `paymasterPostOpGasLimit`, which is excluded
|
|
206
|
+
// from `actualGasCost` (the EntryPoint computes it only after `postOp` returns). See {_postOpGasPenalty}.
|
|
207
|
+
//
|
|
208
|
+
// native cost is computed as: actualGasCost + ((_postOpCost() + penaltyGas) * actualUserOpFeePerGas)
|
|
209
|
+
uint256 actualTokenCost = _erc20Cost(
|
|
210
|
+
_postOpCost().saturatingAdd(penaltyGas).saturatingMul(actualUserOpFeePerGas).saturatingAdd(actualGasCost),
|
|
211
|
+
tokenPerNative
|
|
212
|
+
);
|
|
213
|
+
(bool success, uint256 actualAmount) = _refund(
|
|
214
|
+
token,
|
|
215
|
+
tokenPerNative,
|
|
216
|
+
actualTokenCost,
|
|
217
|
+
actualUserOpFeePerGas,
|
|
218
|
+
prefunder,
|
|
219
|
+
prefundAmount,
|
|
220
|
+
prefundContext
|
|
221
|
+
);
|
|
222
|
+
if (!success) revert PaymasterERC20FailedRefund(token, prefundAmount, actualAmount, prefundContext);
|
|
223
|
+
|
|
224
|
+
emit UserOperationSponsored(userOpHash, address(token), actualAmount, tokenPerNative);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @dev Refunds `prefundAmount - actualAmount` of `token` back to `prefunder` and returns the
|
|
229
|
+
* `actualAmount` actually charged.
|
|
230
|
+
*
|
|
231
|
+
* `actualAmount` is pre-computed by {_postOp} via {_erc20Cost}. Extensions may change it (e.g. a
|
|
232
|
+
* guarantor adds its extra postOp cost or zeroes it out after pulling from the user) and must
|
|
233
|
+
* return the value that was effectively charged.
|
|
234
|
+
*
|
|
235
|
+
* Requirements:
|
|
236
|
+
*
|
|
237
|
+
* - `actualAmount <= prefundAmount`.
|
|
238
|
+
*/
|
|
239
|
+
function _refund(
|
|
240
|
+
IERC20 token,
|
|
241
|
+
uint256 /* tokenPerNative */,
|
|
242
|
+
uint256 actualAmount_,
|
|
243
|
+
uint256 /* actualUserOpFeePerGas */,
|
|
244
|
+
address prefunder,
|
|
245
|
+
uint256 prefundAmount,
|
|
246
|
+
bytes calldata /* prefundContext */
|
|
247
|
+
) internal virtual returns (bool success, uint256 actualAmount) {
|
|
248
|
+
// Under ERC-4337 EntryPoint, `actualGasCost <= maxCost` and `actualUserOpFeePerGas <= maxFeePerGas`,
|
|
249
|
+
// so `actualAmount_ <= prefundAmount` holds.
|
|
250
|
+
return (token.trySafeTransfer(prefunder, prefundAmount - actualAmount_), actualAmount_);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @dev Retrieves payment details for a user operation.
|
|
255
|
+
*
|
|
256
|
+
* The values returned by this internal function are:
|
|
257
|
+
*
|
|
258
|
+
* * `validationData`: ERC-4337 validation data, indicating success/failure and optional time validity (`validAfter`, `validUntil`).
|
|
259
|
+
* * `token`: Address of the ERC-20 token used for payment to the paymaster.
|
|
260
|
+
* * `tokenPerNative`: Token units charged per unit of native currency. This is scaled by `_tokenPerNativeDenominator()`
|
|
261
|
+
* which defaults to 1e18 (wei per eth), making it effectively a number of token units per eth, and not per wei.
|
|
262
|
+
*
|
|
263
|
+
* ==== Calculating the token price
|
|
264
|
+
*
|
|
265
|
+
* `tokenPerNative` is the multiplier {_erc20Cost} applies to a native-currency gas cost to produce a token amount:
|
|
266
|
+
* `tokenAmount = (nativeCost * tokenPerNative) / _tokenPerNativeDenominator()`. Each elements is denominated as follows:
|
|
267
|
+
*
|
|
268
|
+
* * `tokenAmount`: token units.
|
|
269
|
+
* * `nativeCost`: wei.
|
|
270
|
+
* * `tokenPerNative`: token units per eth.
|
|
271
|
+
* * `_tokenPerNativeDenominator()`: wei per native coin (1e18 on EVM chains).
|
|
272
|
+
*
|
|
273
|
+
* For a token priced from USD oracles, derive `tokenPerNative` from the inverse exchange rate:
|
|
274
|
+
*
|
|
275
|
+
* `tokenPerNative = (<Native token price in $> / 1e18) / (<ERC-20 token price in $> / 10**<ERC-20 decimals>) * _tokenPerNativeDenominator()`
|
|
276
|
+
*
|
|
277
|
+
* For example, suppose the token is USDC ($1 with 6 decimals) and the native currency is ETH ($2524.86 with 18 decimals).
|
|
278
|
+
* Then 1 wei of gas costs `(2524.86 / 1e18) / (1 / 1e6) = 2.52486e-9` USDC units, so with
|
|
279
|
+
* `_tokenPerNativeDenominator() = 1e18` we have `tokenPerNative = 2_524_860_000` (i.e. `2.52486e-9 * 1e18`). Charging
|
|
280
|
+
* `actualGasCost` wei yields `actualGasCost * 2_524_860_000 / 1e18` USDC units.
|
|
281
|
+
*/
|
|
282
|
+
function _fetchDetails(
|
|
283
|
+
PackedUserOperation calldata userOp,
|
|
284
|
+
bytes32 userOpHash
|
|
285
|
+
) internal view virtual returns (uint256 validationData, IERC20 token, uint256 tokenPerNative);
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* @dev Over-estimates the cost of the post-operation logic, which the EntryPoint charges to the paymaster but
|
|
289
|
+
* excludes from the `actualGasCost` reported to {_postOp}.
|
|
290
|
+
*
|
|
291
|
+
* NOTE: The default assumes a standard ERC-20. Override with a higher value for gas-heavier tokens; a persistent
|
|
292
|
+
* underestimate drains the paymaster's deposit.
|
|
293
|
+
*
|
|
294
|
+
* NOTE: Extensions that bill extra postOp gas through a separate cost (rather than by widening this virtual)
|
|
295
|
+
* must also widen {_postOpGasBudget} by the same amount, otherwise the extra gas is billed twice: once as cost
|
|
296
|
+
* and once as unused-gas penalty.
|
|
297
|
+
*/
|
|
298
|
+
function _postOpCost() internal view virtual returns (uint256) {
|
|
299
|
+
return 30_000;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @dev Portion of the user-controlled `paymasterPostOpGasLimit` that this paymaster already bills through
|
|
304
|
+
* {_postOpCost}, and on which no unused-gas penalty is therefore charged (see {_postOpGasPenalty}).
|
|
305
|
+
*
|
|
306
|
+
* Extensions that bill extra postOp gas must widen this by the same amount, otherwise the gas they require the
|
|
307
|
+
* sender to provision is billed twice: once as cost, once as penalty.
|
|
308
|
+
*
|
|
309
|
+
* IMPORTANT: The value returned here MUST NOT exceed the total postOp gas the paymaster bills. Combined with
|
|
310
|
+
* {_postOpCost} over-estimating the gas `postOp` actually consumes, that keeps the charge computed in
|
|
311
|
+
* {_validatePaymasterUserOp} above what the EntryPoint debits. A budget larger than what is billed under-prices
|
|
312
|
+
* the penalty and settles operations at a loss.
|
|
313
|
+
*/
|
|
314
|
+
function _postOpGasBudget(PackedUserOperation calldata /* userOp */) internal view virtual returns (uint256) {
|
|
315
|
+
return _postOpCost();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @dev Unused-gas penalty (in gas units) that the EntryPoint charges the paymaster's deposit, given
|
|
320
|
+
* `unusedPostOpGas`: an upper bound on the part of `paymasterPostOpGasLimit` that `postOp` will leave unspent
|
|
321
|
+
* (see {_postOpGasBudget}). This penalty is excluded from the `actualGasCost` reported to {_postOp} (the
|
|
322
|
+
* EntryPoint computes it only after `postOp` returns), so it is priced into the charge during validation and
|
|
323
|
+
* retained in {_postOp}. Without it, a user could inflate `paymasterPostOpGasLimit` and have the paymaster
|
|
324
|
+
* absorb the resulting penalty on every operation, draining its deposit.
|
|
325
|
+
*
|
|
326
|
+
* The default mirrors the 10% penalty the EntryPoint (v0.8-v0.9) applies to unused postOp gas. It deliberately
|
|
327
|
+
* does not reproduce the EntryPoint's 40_000 gas threshold below which no penalty applies: `unusedPostOpGas` is
|
|
328
|
+
* an upper bound on the real unused amount, so claiming that relief here can price the charge below the penalty
|
|
329
|
+
* the EntryPoint actually debits.
|
|
330
|
+
*
|
|
331
|
+
* NOTE: Overrides MUST return an upper bound on the real penalty, otherwise the paymaster settles operations at
|
|
332
|
+
* a loss. Override to return 0 when targeting an EntryPoint that has no unused-gas penalty.
|
|
333
|
+
*/
|
|
334
|
+
function _postOpGasPenalty(uint256 unusedPostOpGas) internal view virtual returns (uint256) {
|
|
335
|
+
return unusedPostOpGas / 10;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/// @dev Denominator used for interpreting the `tokenPerNative` returned by {_fetchDetails} as "fixed point" in {_erc20Cost}.
|
|
339
|
+
function _tokenPerNativeDenominator() internal view virtual returns (uint256) {
|
|
340
|
+
return 1e18;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @dev Lower bound on `tokenPerNative` (see {_fetchDetails} for units). Operations whose `tokenPerNative`
|
|
345
|
+
* is strictly below this value are rejected with `SIG_VALIDATION_FAILED` before {_prefund} runs.
|
|
346
|
+
*
|
|
347
|
+
* To pick a value, decide:
|
|
348
|
+
*
|
|
349
|
+
* * `minCharge`: smallest token amount you want to bill per op (e.g. `0.01 USDC = 10_000` units).
|
|
350
|
+
* * `minGasCost`: smallest `actualGasCost + _postOpCost() * actualUserOpFeePerGas` you expect, in wei
|
|
351
|
+
* (= `minGas * minFeePerGas`; `minFeePerGas` can be as low as 1 wei on some L2s).
|
|
352
|
+
*
|
|
353
|
+
* Then set `_minTokensPerNative() >= minCharge * _tokenPerNativeDenominator() / minGasCost`.
|
|
354
|
+
*
|
|
355
|
+
* Example: a USDC (6 decimals) paymaster on a chain with `minFeePerGas = 1 gwei`, sponsoring
|
|
356
|
+
* ops of at least 100_000 gas and charging at least 0.01 USDC per op:
|
|
357
|
+
*
|
|
358
|
+
* ```solidity
|
|
359
|
+
* function _minTokensPerNative() internal view override returns (uint256) {
|
|
360
|
+
* return 100e6; // = 1e4 (0.01 USDC) * 1e18 / 1e14 (100_000 gas * 1 gwei) = 100 USDC/ETH
|
|
361
|
+
* }
|
|
362
|
+
* ```
|
|
363
|
+
*
|
|
364
|
+
* WARNING: Setting `_minTokensPerNative()` below `minCharge * _tokenPerNativeDenominator() / minGasCost`
|
|
365
|
+
* lets {_erc20Cost} round to zero or to dust for the cheapest ops the paymaster accepts,
|
|
366
|
+
* sponsoring them at a low (or zero) price.
|
|
367
|
+
*/
|
|
368
|
+
function _minTokensPerNative() internal view virtual returns (uint256) {
|
|
369
|
+
return 0;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @dev Calculates native currency cost to ERC-20 token cost.
|
|
374
|
+
*
|
|
375
|
+
* Returns `type(uint256).max` if computation overflows.
|
|
376
|
+
*/
|
|
377
|
+
function _erc20Cost(uint256 nativeCost, uint256 tokenPerNative) internal view virtual returns (uint256) {
|
|
378
|
+
uint256 denominator = _tokenPerNativeDenominator();
|
|
379
|
+
(uint256 high, ) = nativeCost.mul512(tokenPerNative);
|
|
380
|
+
// Round up using a saturating add to avoid possible overflow of the rounding.
|
|
381
|
+
return
|
|
382
|
+
high < denominator
|
|
383
|
+
? nativeCost.mulDiv(tokenPerNative, denominator).saturatingAdd(
|
|
384
|
+
(mulmod(nativeCost, tokenPerNative, denominator) > 0).toUint()
|
|
385
|
+
)
|
|
386
|
+
: type(uint256).max;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/// @dev Internal function that allows the withdrawer to extract ERC-20 tokens resulting from gas payments.
|
|
390
|
+
function _withdrawTokens(IERC20 token, address recipient, uint256 amount) internal virtual {
|
|
391
|
+
if (amount == type(uint256).max) amount = token.balanceOf(address(this));
|
|
392
|
+
token.safeTransfer(recipient, amount);
|
|
393
|
+
}
|
|
394
|
+
}
|