├── README.md ├── foundry.toml ├── interfaces ├── IAaveV2LendingPool.sol ├── IAaveV2LendingPoolAddressProvider.sol ├── IChainLinkAggregatorV3.sol ├── IDelegateApprovals.sol ├── IFund.sol ├── ISynth.sol ├── ISynthetix.sol ├── IUniswapV3SwapRouter.sol ├── IVirtualSynth.sol └── IWETH.sol ├── lib ├── forge-std │ ├── .github │ │ └── workflows │ │ │ └── tests.yml │ ├── .gitignore │ ├── .gitmodules │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── lib │ │ └── ds-test │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── default.nix │ │ │ ├── demo │ │ │ └── demo.sol │ │ │ └── src │ │ │ └── test.sol │ └── src │ │ ├── Script.sol │ │ ├── Test.sol │ │ ├── Vm.sol │ │ ├── console.sol │ │ ├── console2.sol │ │ └── test │ │ ├── Script.t.sol │ │ ├── StdAssertions.t.sol │ │ ├── StdCheats.t.sol │ │ ├── StdError.t.sol │ │ ├── StdMath.t.sol │ │ └── StdStorage.t.sol └── openzeppelin-contracts │ ├── .codecov.yml │ ├── .editorconfig │ ├── .eslintrc │ ├── .gitattributes │ ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── bug_report.md │ │ ├── config.yml │ │ └── feature_request.md │ ├── PULL_REQUEST_TEMPLATE.md │ └── workflows │ │ ├── docs.yml │ │ ├── test.yml │ │ └── upgradeable.yml │ ├── .gitignore │ ├── .mocharc.js │ ├── .prettierrc │ ├── .solcover.js │ ├── .solhint.json │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── DOCUMENTATION.md │ ├── GUIDELINES.md │ ├── LICENSE │ ├── README.md │ ├── RELEASING.md │ ├── SECURITY.md │ ├── audit │ ├── 2017-03.md │ └── 2018-10.pdf │ ├── certora │ ├── Makefile │ ├── README.md │ ├── applyHarness.patch │ ├── harnesses │ │ ├── ERC20VotesHarness.sol │ │ ├── WizardControlFirstPriority.sol │ │ └── WizardFirstTry.sol │ ├── munged │ │ └── .gitignore │ ├── scripts │ │ ├── Governor.sh │ │ ├── GovernorCountingSimple-counting.sh │ │ ├── WizardControlFirstPriority.sh │ │ ├── WizardFirstTry.sh │ │ ├── sanity.sh │ │ └── verifyAll.sh │ └── specs │ │ ├── GovernorBase.spec │ │ ├── GovernorCountingSimple.spec │ │ ├── RulesInProgress.spec │ │ └── sanity.spec │ ├── contracts │ ├── access │ │ ├── AccessControl.sol │ │ ├── AccessControlEnumerable.sol │ │ ├── IAccessControl.sol │ │ ├── IAccessControlEnumerable.sol │ │ ├── Ownable.sol │ │ └── README.adoc │ ├── finance │ │ ├── PaymentSplitter.sol │ │ ├── README.adoc │ │ └── VestingWallet.sol │ ├── governance │ │ ├── Governor.sol │ │ ├── IGovernor.sol │ │ ├── README.adoc │ │ ├── TimelockController.sol │ │ ├── compatibility │ │ │ ├── GovernorCompatibilityBravo.sol │ │ │ └── IGovernorCompatibilityBravo.sol │ │ ├── extensions │ │ │ ├── GovernorCountingSimple.sol │ │ │ ├── GovernorPreventLateQuorum.sol │ │ │ ├── GovernorProposalThreshold.sol │ │ │ ├── GovernorSettings.sol │ │ │ ├── GovernorTimelockCompound.sol │ │ │ ├── GovernorTimelockControl.sol │ │ │ ├── GovernorVotes.sol │ │ │ ├── GovernorVotesComp.sol │ │ │ ├── GovernorVotesQuorumFraction.sol │ │ │ └── IGovernorTimelock.sol │ │ └── utils │ │ │ ├── IVotes.sol │ │ │ └── Votes.sol │ ├── interfaces │ │ ├── IERC1155.sol │ │ ├── IERC1155MetadataURI.sol │ │ ├── IERC1155Receiver.sol │ │ ├── IERC1271.sol │ │ ├── IERC1363.sol │ │ ├── IERC1363Receiver.sol │ │ ├── IERC1363Spender.sol │ │ ├── IERC165.sol │ │ ├── IERC1820Implementer.sol │ │ ├── IERC1820Registry.sol │ │ ├── IERC20.sol │ │ ├── IERC20Metadata.sol │ │ ├── IERC2981.sol │ │ ├── IERC3156.sol │ │ ├── IERC3156FlashBorrower.sol │ │ ├── IERC3156FlashLender.sol │ │ ├── IERC721.sol │ │ ├── IERC721Enumerable.sol │ │ ├── IERC721Metadata.sol │ │ ├── IERC721Receiver.sol │ │ ├── IERC777.sol │ │ ├── IERC777Recipient.sol │ │ ├── IERC777Sender.sol │ │ ├── README.adoc │ │ ├── draft-IERC1822.sol │ │ └── draft-IERC2612.sol │ ├── metatx │ │ ├── ERC2771Context.sol │ │ ├── MinimalForwarder.sol │ │ └── README.adoc │ ├── mocks │ │ ├── AccessControlEnumerableMock.sol │ │ ├── AccessControlMock.sol │ │ ├── AddressImpl.sol │ │ ├── ArraysImpl.sol │ │ ├── BadBeacon.sol │ │ ├── Base64Mock.sol │ │ ├── BitmapMock.sol │ │ ├── CallReceiverMock.sol │ │ ├── CheckpointsImpl.sol │ │ ├── ClashingImplementation.sol │ │ ├── ClonesMock.sol │ │ ├── ConditionalEscrowMock.sol │ │ ├── ContextMock.sol │ │ ├── CountersImpl.sol │ │ ├── Create2Impl.sol │ │ ├── DummyImplementation.sol │ │ ├── ECDSAMock.sol │ │ ├── EIP712External.sol │ │ ├── ERC1155BurnableMock.sol │ │ ├── ERC1155Mock.sol │ │ ├── ERC1155PausableMock.sol │ │ ├── ERC1155ReceiverMock.sol │ │ ├── ERC1155SupplyMock.sol │ │ ├── ERC1271WalletMock.sol │ │ ├── ERC165 │ │ │ ├── ERC165InterfacesSupported.sol │ │ │ ├── ERC165MissingData.sol │ │ │ └── ERC165NotSupported.sol │ │ ├── ERC165CheckerMock.sol │ │ ├── ERC165Mock.sol │ │ ├── ERC165StorageMock.sol │ │ ├── ERC1820ImplementerMock.sol │ │ ├── ERC20BurnableMock.sol │ │ ├── ERC20CappedMock.sol │ │ ├── ERC20DecimalsMock.sol │ │ ├── ERC20FlashMintMock.sol │ │ ├── ERC20Mock.sol │ │ ├── ERC20PausableMock.sol │ │ ├── ERC20PermitMock.sol │ │ ├── ERC20SnapshotMock.sol │ │ ├── ERC20VotesCompMock.sol │ │ ├── ERC20VotesMock.sol │ │ ├── ERC20WrapperMock.sol │ │ ├── ERC2771ContextMock.sol │ │ ├── ERC3156FlashBorrowerMock.sol │ │ ├── ERC721BurnableMock.sol │ │ ├── ERC721EnumerableMock.sol │ │ ├── ERC721Mock.sol │ │ ├── ERC721PausableMock.sol │ │ ├── ERC721ReceiverMock.sol │ │ ├── ERC721RoyaltyMock.sol │ │ ├── ERC721URIStorageMock.sol │ │ ├── ERC721VotesMock.sol │ │ ├── ERC777Mock.sol │ │ ├── ERC777SenderRecipientMock.sol │ │ ├── EnumerableMapMock.sol │ │ ├── EnumerableSetMock.sol │ │ ├── EtherReceiverMock.sol │ │ ├── GovernorCompMock.sol │ │ ├── GovernorCompatibilityBravoMock.sol │ │ ├── GovernorMock.sol │ │ ├── GovernorPreventLateQuorumMock.sol │ │ ├── GovernorTimelockCompoundMock.sol │ │ ├── GovernorTimelockControlMock.sol │ │ ├── GovernorVoteMock.sol │ │ ├── InitializableMock.sol │ │ ├── MathMock.sol │ │ ├── MerkleProofWrapper.sol │ │ ├── MulticallTest.sol │ │ ├── MulticallTokenMock.sol │ │ ├── MultipleInheritanceInitializableMocks.sol │ │ ├── OwnableMock.sol │ │ ├── PausableMock.sol │ │ ├── PullPaymentMock.sol │ │ ├── ReentrancyAttack.sol │ │ ├── ReentrancyMock.sol │ │ ├── RegressionImplementation.sol │ │ ├── SafeCastMock.sol │ │ ├── SafeERC20Helper.sol │ │ ├── SafeMathMock.sol │ │ ├── SignatureCheckerMock.sol │ │ ├── SignedMathMock.sol │ │ ├── SignedSafeMathMock.sol │ │ ├── SingleInheritanceInitializableMocks.sol │ │ ├── StorageSlotMock.sol │ │ ├── StringsMock.sol │ │ ├── TimersBlockNumberImpl.sol │ │ ├── TimersTimestampImpl.sol │ │ ├── UUPS │ │ │ ├── UUPSLegacy.sol │ │ │ └── UUPSUpgradeableMock.sol │ │ ├── VotesMock.sol │ │ ├── compound │ │ │ └── CompTimelock.sol │ │ └── wizard │ │ │ ├── MyGovernor1.sol │ │ │ ├── MyGovernor2.sol │ │ │ └── MyGovernor3.sol │ ├── package.json │ ├── proxy │ │ ├── Clones.sol │ │ ├── ERC1967 │ │ │ ├── ERC1967Proxy.sol │ │ │ └── ERC1967Upgrade.sol │ │ ├── Proxy.sol │ │ ├── README.adoc │ │ ├── beacon │ │ │ ├── BeaconProxy.sol │ │ │ ├── IBeacon.sol │ │ │ └── UpgradeableBeacon.sol │ │ ├── transparent │ │ │ ├── ProxyAdmin.sol │ │ │ └── TransparentUpgradeableProxy.sol │ │ └── utils │ │ │ ├── Initializable.sol │ │ │ └── UUPSUpgradeable.sol │ ├── security │ │ ├── Pausable.sol │ │ ├── PullPayment.sol │ │ ├── README.adoc │ │ └── ReentrancyGuard.sol │ ├── token │ │ ├── ERC1155 │ │ │ ├── ERC1155.sol │ │ │ ├── IERC1155.sol │ │ │ ├── IERC1155Receiver.sol │ │ │ ├── README.adoc │ │ │ ├── extensions │ │ │ │ ├── ERC1155Burnable.sol │ │ │ │ ├── ERC1155Pausable.sol │ │ │ │ ├── ERC1155Supply.sol │ │ │ │ └── IERC1155MetadataURI.sol │ │ │ ├── presets │ │ │ │ ├── ERC1155PresetMinterPauser.sol │ │ │ │ └── README.md │ │ │ └── utils │ │ │ │ ├── ERC1155Holder.sol │ │ │ │ └── ERC1155Receiver.sol │ │ ├── ERC20 │ │ │ ├── ERC20.sol │ │ │ ├── IERC20.sol │ │ │ ├── README.adoc │ │ │ ├── extensions │ │ │ │ ├── ERC20Burnable.sol │ │ │ │ ├── ERC20Capped.sol │ │ │ │ ├── ERC20FlashMint.sol │ │ │ │ ├── ERC20Pausable.sol │ │ │ │ ├── ERC20Snapshot.sol │ │ │ │ ├── ERC20Votes.sol │ │ │ │ ├── ERC20VotesComp.sol │ │ │ │ ├── ERC20Wrapper.sol │ │ │ │ ├── IERC20Metadata.sol │ │ │ │ ├── draft-ERC20Permit.sol │ │ │ │ └── draft-IERC20Permit.sol │ │ │ ├── presets │ │ │ │ ├── ERC20PresetFixedSupply.sol │ │ │ │ ├── ERC20PresetMinterPauser.sol │ │ │ │ └── README.md │ │ │ └── utils │ │ │ │ ├── SafeERC20.sol │ │ │ │ └── TokenTimelock.sol │ │ ├── ERC721 │ │ │ ├── ERC721.sol │ │ │ ├── IERC721.sol │ │ │ ├── IERC721Receiver.sol │ │ │ ├── README.adoc │ │ │ ├── extensions │ │ │ │ ├── ERC721Burnable.sol │ │ │ │ ├── ERC721Enumerable.sol │ │ │ │ ├── ERC721Pausable.sol │ │ │ │ ├── ERC721Royalty.sol │ │ │ │ ├── ERC721URIStorage.sol │ │ │ │ ├── IERC721Enumerable.sol │ │ │ │ ├── IERC721Metadata.sol │ │ │ │ └── draft-ERC721Votes.sol │ │ │ ├── presets │ │ │ │ ├── ERC721PresetMinterPauserAutoId.sol │ │ │ │ └── README.md │ │ │ └── utils │ │ │ │ └── ERC721Holder.sol │ │ ├── ERC777 │ │ │ ├── ERC777.sol │ │ │ ├── IERC777.sol │ │ │ ├── IERC777Recipient.sol │ │ │ ├── IERC777Sender.sol │ │ │ ├── README.adoc │ │ │ └── presets │ │ │ │ └── ERC777PresetFixedSupply.sol │ │ └── common │ │ │ ├── ERC2981.sol │ │ │ └── README.adoc │ └── utils │ │ ├── Address.sol │ │ ├── Arrays.sol │ │ ├── Base64.sol │ │ ├── Checkpoints.sol │ │ ├── Context.sol │ │ ├── Counters.sol │ │ ├── Create2.sol │ │ ├── Multicall.sol │ │ ├── README.adoc │ │ ├── StorageSlot.sol │ │ ├── Strings.sol │ │ ├── Timers.sol │ │ ├── cryptography │ │ ├── ECDSA.sol │ │ ├── MerkleProof.sol │ │ ├── SignatureChecker.sol │ │ └── draft-EIP712.sol │ │ ├── escrow │ │ ├── ConditionalEscrow.sol │ │ ├── Escrow.sol │ │ └── RefundEscrow.sol │ │ ├── introspection │ │ ├── ERC165.sol │ │ ├── ERC165Checker.sol │ │ ├── ERC165Storage.sol │ │ ├── ERC1820Implementer.sol │ │ ├── IERC165.sol │ │ ├── IERC1820Implementer.sol │ │ └── IERC1820Registry.sol │ │ ├── math │ │ ├── Math.sol │ │ ├── SafeCast.sol │ │ ├── SafeMath.sol │ │ ├── SignedMath.sol │ │ └── SignedSafeMath.sol │ │ └── structs │ │ ├── BitMaps.sol │ │ ├── EnumerableMap.sol │ │ └── EnumerableSet.sol │ ├── docs │ ├── antora.yml │ ├── contract.hbs │ ├── helpers.js │ ├── modules │ │ └── ROOT │ │ │ ├── images │ │ │ ├── tally-admin.png │ │ │ └── tally-vote.png │ │ │ ├── nav.adoc │ │ │ └── pages │ │ │ ├── access-control.adoc │ │ │ ├── crowdsales.adoc │ │ │ ├── drafts.adoc │ │ │ ├── erc1155.adoc │ │ │ ├── erc20-supply.adoc │ │ │ ├── erc20.adoc │ │ │ ├── erc721.adoc │ │ │ ├── erc777.adoc │ │ │ ├── extending-contracts.adoc │ │ │ ├── governance.adoc │ │ │ ├── index.adoc │ │ │ ├── releases-stability.adoc │ │ │ ├── tokens.adoc │ │ │ ├── upgradeable.adoc │ │ │ ├── utilities.adoc │ │ │ └── wizard.adoc │ └── prelude.hbs │ ├── hardhat.config.js │ ├── hardhat │ └── env-contract.js │ ├── logo.svg │ ├── migrations │ └── .gitkeep │ ├── netlify.toml │ ├── package-lock.json │ ├── package.json │ ├── renovate.json │ ├── scripts │ ├── gen-nav.js │ ├── git-user-config.sh │ ├── inheritanceOrdering.js │ ├── migrate-imports.js │ ├── prepack.sh │ ├── prepare-contracts-package.sh │ ├── prepare-docs-solc.js │ ├── prepare-docs.sh │ ├── release │ │ ├── release.sh │ │ ├── synchronize-versions.js │ │ ├── update-changelog-release-date.js │ │ ├── update-comment.js │ │ └── version.sh │ ├── remove-ignored-artifacts.js │ └── update-docs-branch.js │ └── test │ ├── TESTING.md │ ├── access │ ├── AccessControl.behavior.js │ ├── AccessControl.test.js │ ├── AccessControlEnumerable.test.js │ └── Ownable.test.js │ ├── finance │ ├── PaymentSplitter.test.js │ ├── VestingWallet.behavior.js │ └── VestingWallet.test.js │ ├── governance │ ├── Governor.test.js │ ├── GovernorWorkflow.behavior.js │ ├── TimelockController.test.js │ ├── compatibility │ │ └── GovernorCompatibilityBravo.test.js │ ├── extensions │ │ ├── GovernorComp.test.js │ │ ├── GovernorERC721.test.js │ │ ├── GovernorPreventLateQuorum.test.js │ │ ├── GovernorTimelockCompound.test.js │ │ ├── GovernorTimelockControl.test.js │ │ └── GovernorWeightQuorumFraction.test.js │ └── utils │ │ ├── Votes.behavior.js │ │ └── Votes.test.js │ ├── helpers │ ├── eip712.js │ ├── enums.js │ ├── erc1967.js │ └── sign.js │ ├── metatx │ ├── ERC2771Context.test.js │ └── MinimalForwarder.test.js │ ├── migrate-imports.test.js │ ├── proxy │ ├── Clones.behaviour.js │ ├── Clones.test.js │ ├── ERC1967 │ │ └── ERC1967Proxy.test.js │ ├── Proxy.behaviour.js │ ├── beacon │ │ ├── BeaconProxy.test.js │ │ └── UpgradeableBeacon.test.js │ ├── transparent │ │ ├── ProxyAdmin.test.js │ │ ├── TransparentUpgradeableProxy.behaviour.js │ │ └── TransparentUpgradeableProxy.test.js │ └── utils │ │ ├── Initializable.test.js │ │ └── UUPSUpgradeable.test.js │ ├── security │ ├── Pausable.test.js │ ├── PullPayment.test.js │ └── ReentrancyGuard.test.js │ ├── token │ ├── ERC1155 │ │ ├── ERC1155.behavior.js │ │ ├── ERC1155.test.js │ │ ├── extensions │ │ │ ├── ERC1155Burnable.test.js │ │ │ ├── ERC1155Pausable.test.js │ │ │ └── ERC1155Supply.test.js │ │ ├── presets │ │ │ └── ERC1155PresetMinterPauser.test.js │ │ └── utils │ │ │ └── ERC1155Holder.test.js │ ├── ERC20 │ │ ├── ERC20.behavior.js │ │ ├── ERC20.test.js │ │ ├── extensions │ │ │ ├── ERC20Burnable.behavior.js │ │ │ ├── ERC20Burnable.test.js │ │ │ ├── ERC20Capped.behavior.js │ │ │ ├── ERC20Capped.test.js │ │ │ ├── ERC20FlashMint.test.js │ │ │ ├── ERC20Pausable.test.js │ │ │ ├── ERC20Snapshot.test.js │ │ │ ├── ERC20Votes.test.js │ │ │ ├── ERC20VotesComp.test.js │ │ │ ├── ERC20Wrapper.test.js │ │ │ └── draft-ERC20Permit.test.js │ │ ├── presets │ │ │ ├── ERC20PresetFixedSupply.test.js │ │ │ └── ERC20PresetMinterPauser.test.js │ │ └── utils │ │ │ ├── SafeERC20.test.js │ │ │ └── TokenTimelock.test.js │ ├── ERC721 │ │ ├── ERC721.behavior.js │ │ ├── ERC721.test.js │ │ ├── ERC721Enumerable.test.js │ │ ├── extensions │ │ │ ├── ERC721Burnable.test.js │ │ │ ├── ERC721Pausable.test.js │ │ │ ├── ERC721Royalty.test.js │ │ │ ├── ERC721URIStorage.test.js │ │ │ └── ERC721Votes.test.js │ │ ├── presets │ │ │ └── ERC721PresetMinterPauserAutoId.test.js │ │ └── utils │ │ │ └── ERC721Holder.test.js │ ├── ERC777 │ │ ├── ERC777.behavior.js │ │ ├── ERC777.test.js │ │ └── presets │ │ │ └── ERC777PresetFixedSupply.test.js │ └── common │ │ └── ERC2981.behavior.js │ └── utils │ ├── Address.test.js │ ├── Arrays.test.js │ ├── Base64.test.js │ ├── Checkpoints.test.js │ ├── Context.behavior.js │ ├── Context.test.js │ ├── Counters.test.js │ ├── Create2.test.js │ ├── Multicall.test.js │ ├── StorageSlot.test.js │ ├── Strings.test.js │ ├── TimersBlockNumberImpl.test.js │ ├── TimersTimestamp.test.js │ ├── cryptography │ ├── ECDSA.test.js │ ├── MerkleProof.test.js │ ├── SignatureChecker.test.js │ └── draft-EIP712.test.js │ ├── escrow │ ├── ConditionalEscrow.test.js │ ├── Escrow.behavior.js │ ├── Escrow.test.js │ └── RefundEscrow.test.js │ ├── introspection │ ├── ERC165.test.js │ ├── ERC165Checker.test.js │ ├── ERC165Storage.test.js │ ├── ERC1820Implementer.test.js │ └── SupportsInterface.behavior.js │ ├── math │ ├── Math.test.js │ ├── SafeCast.test.js │ ├── SafeMath.test.js │ ├── SignedMath.test.js │ └── SignedSafeMath.test.js │ └── structs │ ├── BitMap.test.js │ ├── EnumerableMap.test.js │ ├── EnumerableSet.behavior.js │ └── EnumerableSet.test.js ├── remappings.txt ├── src ├── Fund.sol ├── adapters │ ├── AaveV2.sol │ ├── Synthetix.sol │ └── UniswapV3.sol └── mock │ └── WETH.sol └── test ├── ForkMainnet.t.sol ├── HelloFork.t.sol └── Integration.t.sol /README.md: -------------------------------------------------------------------------------- 1 | # Secure DeFi smart contract development on Ethereum 2 | 3 | ## Setup 4 | 5 | ### Alchemy 6 | 7 | * Go to [Alchemy](ttps://dashboard.alchemyapi.io/). 8 | * Create an API key for Alchemy by creating a new app. 9 | 10 | ### Docker or install Foundry 11 | 12 | For Docker: 13 | 14 | ``docker pull ghcr.io/foundry-rs/foundry:latest`` 15 | 16 | ``docker run --rm -v $PWD:/shared/ -it --entrypoint /bin/sh ghcr.io/foundry-rs/foundry`` 17 | 18 | For [Foundry](https://github.com/foundry-rs/foundry): 19 | 20 | ``curl -L https://foundry.paradigm.xyz | bash`` 21 | 22 | and then restart your terminal and run ``foundryup``. 23 | 24 | ### Last Step 25 | 26 | You should be able to run successfully the following command: 27 | 28 | ``forge test --fork-url https://eth-mainnet.alchemyapi.io/v2/ --match Fork`` 29 | 30 | ## Foundry Cheatsheet 31 | 32 | * ``vm.prank(address)``: execute the next call as an arbitrary address 33 | * ``vm.startPrank(address)`` 34 | * ``vm.stopPrank()`` 35 | 36 | ### Fuzzing 37 | 38 | * ``function foo(fuzzedValue)`` 39 | * ``vm.assume(bool)`` 40 | 41 | ### Mainnet fork 42 | 43 | * ``forge test --fork-url https://eth-mainnet.alchemyapi.io/v2/ --match `` 44 | -------------------------------------------------------------------------------- /foundry.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | src = 'src' 3 | out = 'out' 4 | libs = ['lib'] 5 | 6 | # See more config options https://github.com/foundry-rs/foundry/tree/master/config 7 | -------------------------------------------------------------------------------- /interfaces/IAaveV2LendingPool.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: agpl-3.0 2 | pragma solidity 0.8.13; 3 | 4 | interface IAaveV2LendingPool { 5 | function deposit( 6 | address asset, 7 | uint256 amount, 8 | address onBehalfOf, 9 | uint16 referralCode 10 | ) external; 11 | 12 | function withdraw( 13 | address asset, 14 | uint256 amount, 15 | address to 16 | ) external returns (uint256); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /interfaces/IAaveV2LendingPoolAddressProvider.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.13; 2 | 3 | interface IAaveV2LendingPoolAddressProvider { 4 | 5 | function getLendingPool() external view returns (address); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /interfaces/IChainLinkAggregatorV3.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.0; 3 | 4 | interface IChainLinkAggregatorV3 { 5 | function decimals() external view returns (uint8); 6 | 7 | function description() external view returns (string memory); 8 | 9 | function version() external view returns (uint256); 10 | 11 | // getRoundData and latestRoundData should both raise "No data present" 12 | // if they do not have data to report, instead of returning unset values 13 | // which could be misinterpreted as actual reported values. 14 | function getRoundData(uint80 _roundId) 15 | external 16 | view 17 | returns ( 18 | uint80 roundId, 19 | int256 answer, 20 | uint256 startedAt, 21 | uint256 updatedAt, 22 | uint80 answeredInRound 23 | ); 24 | 25 | function latestRoundData() 26 | external 27 | view 28 | returns ( 29 | uint80 roundId, 30 | int256 answer, 31 | uint256 startedAt, 32 | uint256 updatedAt, 33 | uint80 answeredInRound 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /interfaces/IDelegateApprovals.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.24; 2 | 3 | // https://docs.synthetix.io/contracts/source/interfaces/idelegateapprovals 4 | interface IDelegateApprovals { 5 | // Views 6 | function canBurnFor(address authoriser, address delegate) external view returns (bool); 7 | 8 | function canIssueFor(address authoriser, address delegate) external view returns (bool); 9 | 10 | function canClaimFor(address authoriser, address delegate) external view returns (bool); 11 | 12 | function canExchangeFor(address authoriser, address delegate) external view returns (bool); 13 | 14 | // Mutative 15 | function approveAllDelegatePowers(address delegate) external; 16 | 17 | function removeAllDelegatePowers(address delegate) external; 18 | 19 | function approveBurnOnBehalf(address delegate) external; 20 | 21 | function removeBurnOnBehalf(address delegate) external; 22 | 23 | function approveIssueOnBehalf(address delegate) external; 24 | 25 | function removeIssueOnBehalf(address delegate) external; 26 | 27 | function approveClaimOnBehalf(address delegate) external; 28 | 29 | function removeClaimOnBehalf(address delegate) external; 30 | 31 | function approveExchangeOnBehalf(address delegate) external; 32 | 33 | function removeExchangeOnBehalf(address delegate) external; 34 | } 35 | -------------------------------------------------------------------------------- /interfaces/IFund.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.13; 2 | 3 | import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; 4 | import "openzeppelin-contracts/contracts/access/Ownable.sol"; 5 | import "interfaces/IChainLinkAggregatorV3.sol"; 6 | import "interfaces/IDelegateApprovals.sol"; 7 | import {console} from "forge-std/console.sol"; 8 | 9 | interface IFund is ERC20, Ownable{ 10 | 11 | function addToken(address token) external; 12 | 13 | function removeToken(address token) external; 14 | 15 | function modifyRegistry(address adapter, bool value) external; 16 | 17 | function modifyPriceFeeds(address token, address priceFeed) external; 18 | 19 | function estimate() view public returns (uint256){ 20 | 21 | function pricePerShare() view external returns (uint); 22 | 23 | function deposit(uint amount) external; 24 | 25 | function withdraw(uint sharesAmount) external; 26 | 27 | function manage(address outToken, uint amount, address inToken, address target, bytes calldata data) external; 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /interfaces/ISynth.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.24; 2 | 3 | // https://docs.synthetix.io/contracts/source/interfaces/isynth 4 | interface ISynth { 5 | // Views 6 | function currencyKey() external view returns (bytes32); 7 | 8 | function transferableSynths(address account) external view returns (uint); 9 | 10 | // Mutative functions 11 | function transferAndSettle(address to, uint value) external returns (bool); 12 | 13 | function transferFromAndSettle( 14 | address from, 15 | address to, 16 | uint value 17 | ) external returns (bool); 18 | 19 | // Restricted: used internally to Synthetix 20 | function burn(address account, uint amount) external; 21 | 22 | function issue(address account, uint amount) external; 23 | } 24 | -------------------------------------------------------------------------------- /interfaces/IUniswapV3SwapRouter.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | pragma experimental ABIEncoderV2; 3 | 4 | interface IUniswapV3SwapRouter { 5 | struct ExactInputParams { 6 | bytes path; 7 | address recipient; 8 | uint256 deadline; 9 | uint256 amountIn; 10 | uint256 amountOutMinimum; 11 | } 12 | 13 | function exactInput(ExactInputParams calldata) external payable returns (uint256); 14 | } 15 | -------------------------------------------------------------------------------- /interfaces/IVirtualSynth.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.24; 2 | 3 | import "./ISynth.sol"; 4 | 5 | interface IVirtualSynth { 6 | // Views 7 | function balanceOfUnderlying(address account) external view returns (uint); 8 | 9 | function rate() external view returns (uint); 10 | 11 | function readyToSettle() external view returns (bool); 12 | 13 | function secsLeftInWaitingPeriod() external view returns (uint); 14 | 15 | function settled() external view returns (bool); 16 | 17 | function synth() external view returns (ISynth); 18 | 19 | // Mutative functions 20 | function settle(address account) external; 21 | } 22 | -------------------------------------------------------------------------------- /interfaces/IWETH.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.13; 2 | 3 | interface IWETH { 4 | function deposit() external payable; 5 | function transfer(address to, uint value) external returns (bool); 6 | function withdraw(uint) external; 7 | function balanceOf(address who) external view returns (uint256); 8 | function approve(address _spender, uint256 _value) external returns (bool success); 9 | } 10 | -------------------------------------------------------------------------------- /lib/forge-std/.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | check: 6 | name: Foundry project 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | with: 11 | submodules: recursive 12 | 13 | - name: Install Foundry 14 | uses: onbjerg/foundry-toolchain@v1 15 | with: 16 | version: nightly 17 | 18 | - name: Install dependencies 19 | run: forge install 20 | - name: Run tests 21 | run: forge test -vvv 22 | - name: Build Test with older solc versions 23 | run: | 24 | forge build --contracts src/Test.sol --use solc:0.8.0 25 | forge build --contracts src/Test.sol --use solc:0.7.0 26 | forge build --contracts src/Test.sol --use solc:0.6.0 27 | -------------------------------------------------------------------------------- /lib/forge-std/.gitignore: -------------------------------------------------------------------------------- 1 | cache/ 2 | out/ 3 | .vscode 4 | .idea -------------------------------------------------------------------------------- /lib/forge-std/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | -------------------------------------------------------------------------------- /lib/forge-std/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 Brock Elmore 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE O THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE.R 26 | -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/.gitignore: -------------------------------------------------------------------------------- 1 | /.dapple 2 | /build 3 | /out 4 | -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/Makefile: -------------------------------------------------------------------------------- 1 | all:; dapp build 2 | 3 | test: 4 | -dapp --use solc:0.4.23 build 5 | -dapp --use solc:0.4.26 build 6 | -dapp --use solc:0.5.17 build 7 | -dapp --use solc:0.6.12 build 8 | -dapp --use solc:0.7.5 build 9 | 10 | demo: 11 | DAPP_SRC=demo dapp --use solc:0.7.5 build 12 | -hevm dapp-test --verbose 3 13 | 14 | .PHONY: test demo 15 | -------------------------------------------------------------------------------- /lib/forge-std/lib/ds-test/default.nix: -------------------------------------------------------------------------------- 1 | { solidityPackage, dappsys }: solidityPackage { 2 | name = "ds-test"; 3 | src = ./src; 4 | } 5 | -------------------------------------------------------------------------------- /lib/forge-std/src/Script.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Unlicense 2 | pragma solidity >=0.6.0 <0.9.0; 3 | 4 | import "./Vm.sol"; 5 | import "./console.sol"; 6 | import "./console2.sol"; 7 | 8 | abstract contract Script { 9 | bool public IS_SCRIPT = true; 10 | address constant private VM_ADDRESS = 11 | address(bytes20(uint160(uint256(keccak256('hevm cheat code'))))); 12 | 13 | Vm public constant vm = Vm(VM_ADDRESS); 14 | } 15 | -------------------------------------------------------------------------------- /lib/forge-std/src/test/Script.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity >=0.7.0 <0.9.0; 3 | 4 | import "../Test.sol"; 5 | 6 | contract ScriptTest is Test 7 | { 8 | function testGenerateCorrectAddress() external { 9 | address creation = computeCreateAddress(0x6C9FC64A53c1b71FB3f9Af64d1ae3A4931A5f4E9, 14); 10 | assertEq(creation, 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45); 11 | } 12 | } -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: off 2 | github_checks: 3 | annotations: false 4 | coverage: 5 | status: 6 | patch: 7 | default: 8 | target: 95% 9 | project: 10 | default: 11 | threshold: 1% 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | end_of_line = lf 9 | indent_style = space 10 | insert_final_newline = true 11 | trim_trailing_whitespace = false 12 | max_line_length = 120 13 | 14 | [*.sol] 15 | indent_size = 4 16 | 17 | [*.js] 18 | indent_size = 2 19 | 20 | [*.adoc] 21 | max_line_length = 0 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.gitattributes: -------------------------------------------------------------------------------- 1 | *.sol linguist-language=Solidity 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report a bug in OpenZeppelin Contracts 4 | 5 | --- 6 | 7 | 8 | 9 | 10 | 11 | **💻 Environment** 12 | 13 | 14 | 15 | **📝 Details** 16 | 17 | 18 | 19 | **🔢 Code to reproduce bug** 20 | 21 | 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Support request 3 | url: https://forum.openzeppelin.com/c/support/contracts/18 4 | about: Ask the community in the Community Forum 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for OpenZeppelin Contracts 4 | 5 | --- 6 | 7 | **🧐 Motivation** 8 | 9 | 10 | **📝 Details** 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Fixes #???? 7 | 8 | 9 | 10 | 11 | 12 | #### PR Checklist 13 | 14 | 15 | 16 | 17 | 18 | - [ ] Tests 19 | - [ ] Documentation 20 | - [ ] Changelog entry 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Build Docs 2 | 3 | on: 4 | push: 5 | branches: [release-v*] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v2 13 | with: 14 | node-version: 12.x 15 | - uses: actions/cache@v2 16 | id: cache 17 | with: 18 | path: '**/node_modules' 19 | key: npm-v2-${{ hashFiles('**/package-lock.json') }} 20 | restore-keys: npm-v2- 21 | - run: npm ci 22 | if: steps.cache.outputs.cache-hit != 'true' 23 | - run: bash scripts/git-user-config.sh 24 | - run: node scripts/update-docs-branch.js 25 | - run: git push --all origin 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - release-v* 8 | pull_request: {} 9 | workflow_dispatch: {} 10 | 11 | jobs: 12 | test: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v2 16 | - uses: actions/setup-node@v2 17 | with: 18 | node-version: 12.x 19 | - uses: actions/cache@v2 20 | id: cache 21 | with: 22 | path: '**/node_modules' 23 | key: npm-v2-${{ hashFiles('**/package-lock.json') }} 24 | restore-keys: npm-v2- 25 | - run: npm ci 26 | if: steps.cache.outputs.cache-hit != 'true' 27 | - run: npm run lint 28 | - run: npm run test 29 | env: 30 | FORCE_COLOR: 1 31 | ENABLE_GAS_REPORT: true 32 | - run: npm run test:inheritance 33 | - name: Print gas report 34 | run: cat gas-report.txt 35 | 36 | coverage: 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@v2 40 | with: 41 | fetch-depth: 2 42 | - uses: actions/setup-node@v2 43 | with: 44 | node-version: 12.x 45 | - uses: actions/cache@v2 46 | id: cache 47 | with: 48 | path: '**/node_modules' 49 | key: npm-v2-${{ hashFiles('**/package-lock.json') }} 50 | restore-keys: npm-v2- 51 | - run: npm ci 52 | if: steps.cache.outputs.cache-hit != 'true' 53 | - run: npm run coverage 54 | env: 55 | NODE_OPTIONS: --max_old_space_size=4096 56 | - uses: codecov/codecov-action@v2 57 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.github/workflows/upgradeable.yml: -------------------------------------------------------------------------------- 1 | name: Upgradeable Trigger 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - release-v* 8 | 9 | jobs: 10 | trigger: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - id: app 14 | uses: getsentry/action-github-app-token@v1 15 | with: 16 | app_id: ${{ secrets.UPGRADEABLE_APP_ID }} 17 | private_key: ${{ secrets.UPGRADEABLE_APP_PK }} 18 | - run: | 19 | curl -X POST \ 20 | https://api.github.com/repos/OpenZeppelin/openzeppelin-contracts-upgradeable/dispatches \ 21 | -H 'Accept: application/vnd.github.v3+json' \ 22 | -H 'Authorization: token ${{ steps.app.outputs.token }}' \ 23 | -d '{ "event_type": "Update", "client_payload": { "ref": "${{ github.ref }}" } }' 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | 4 | # Logs 5 | logs 6 | *.log 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | allFiredEvents 13 | scTopics 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | coverage.json 18 | coverageEnv 19 | 20 | # node-waf configuration 21 | .lock-wscript 22 | 23 | # Dependency directory 24 | node_modules 25 | 26 | # Debug log from npm 27 | npm-debug.log 28 | 29 | # local env variables 30 | .env 31 | 32 | # truffle build directory 33 | build/ 34 | 35 | # macOS 36 | .DS_Store 37 | 38 | # truffle 39 | .node-xmlhttprequest-* 40 | 41 | # IntelliJ IDE 42 | .idea 43 | 44 | # docs artifacts 45 | docs/modules/api 46 | 47 | # only used to package @openzeppelin/contracts 48 | contracts/build/ 49 | contracts/README.md 50 | 51 | # temporary artifact from solidity-coverage 52 | allFiredEvents 53 | .coverage_artifacts 54 | .coverage_cache 55 | .coverage_contracts 56 | 57 | # hardhat 58 | cache 59 | artifacts 60 | 61 | # Certora 62 | .certora* 63 | .last_confs 64 | certora_* 65 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.mocharc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | require: 'hardhat/register', 3 | timeout: 4000, 4 | }; 5 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": "*.sol", 5 | "options": { 6 | "printWidth": 120, 7 | "explicitTypes": "always" 8 | } 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.solcover.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | norpc: true, 3 | testCommand: 'npm test', 4 | compileCommand: 'npm run compile', 5 | skipFiles: [ 6 | 'mocks', 7 | ], 8 | providerOptions: { 9 | default_balance_ether: '10000000000000000000000000', 10 | }, 11 | mocha: { 12 | fgrep: '[skip-on-coverage]', 13 | invert: true, 14 | }, 15 | } 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/.solhint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-unused-vars": "error", 4 | "const-name-snakecase": "error", 5 | "contract-name-camelcase": "error", 6 | "event-name-camelcase": "error", 7 | "func-name-mixedcase": "error", 8 | "func-param-name-mixedcase": "error", 9 | "modifier-name-mixedcase": "error", 10 | "private-vars-leading-underscore": "error", 11 | "var-name-mixedcase": "error", 12 | "imports-on-top": "error" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/DOCUMENTATION.md: -------------------------------------------------------------------------------- 1 | Documentation is hosted at https://docs.openzeppelin.com/contracts. 2 | 3 | All of the content for the site is in this repository. The guides are in the 4 | [docs](/docs) directory, and the API Reference is extracted from comments in 5 | the source code. If you want to help improve the content, this is the 6 | repository you should be contributing to. 7 | 8 | [`solidity-docgen`](https://github.com/OpenZeppelin/solidity-docgen) is the 9 | program that extracts the API Reference from source code. 10 | 11 | The [`docs.openzeppelin.com`](https://github.com/OpenZeppelin/docs.openzeppelin.com) 12 | repository hosts the configuration for the entire site, which includes 13 | documentation for all of the OpenZeppelin projects. 14 | 15 | To run the docs locally you should run `npm run docs:watch` on this 16 | repository. 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2020 zOS Global Limited 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Releasing 2 | 3 | > Visit the documentation for [details about release schedule]. 4 | 5 | Start on an up-to-date `master` branch. 6 | 7 | Create the release branch with `npm run release start minor`. 8 | 9 | Publish a release candidate with `npm run release rc`. 10 | 11 | Publish the final release with `npm run release final`. 12 | 13 | Follow the general [OpenZeppelin Contracts release checklist]. 14 | 15 | [details about release schedule]: https://docs.openzeppelin.com/contracts/releases-stability 16 | [OpenZeppelin Contracts release checklist]: https://github.com/OpenZeppelin/code-style/blob/master/RELEASE_CHECKLIST.md 17 | 18 | 19 | ## Merging the release branch 20 | 21 | After the final release, the release branch should be merged back into `master`. This merge must not be squashed because it would lose the tagged release commit. Since the GitHub repo is set up to only allow squashed merges, the merge should be done locally and pushed. 22 | 23 | Make sure to have the latest changes from `upstream` in your local release branch. 24 | 25 | ``` 26 | git checkout release-vX.Y.Z 27 | git pull upstream 28 | ``` 29 | 30 | ``` 31 | git checkout master 32 | git merge --no-ff release-vX.Y.Z 33 | git push upstream master 34 | ``` 35 | 36 | The release branch can then be deleted on GitHub. 37 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Bug Bounty 4 | 5 | We have a [**bug bounty program** on Immunefi](https://www.immunefi.com/bounty/openzeppelin). Please report any security issues you find through the Immunefi dashboard, or reach out to security@openzeppelin.com. 6 | 7 | Critical bug fixes will be backported to past major releases. 8 | 9 | ## Supported Versions 10 | 11 | The recommendation is to use the latest version available. 12 | 13 | | Version | Supported | 14 | | ------- | ------------------------------------ | 15 | | 4.x | :white_check_mark::white_check_mark: | 16 | | 3.4 | :white_check_mark: | 17 | | 2.5 | :white_check_mark: | 18 | | < 2.0 | :x: | 19 | 20 | Note that the Solidity language itself only guarantees security updates for the latest release. 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/audit/2018-10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DominicChainsecurity/DevconVI/30da17f0f2cfa0169d87c73c7270ab70ea21855d/lib/openzeppelin-contracts/audit/2018-10.pdf -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/Makefile: -------------------------------------------------------------------------------- 1 | default: help 2 | 3 | PATCH = applyHarness.patch 4 | CONTRACTS_DIR = ../contracts 5 | MUNGED_DIR = munged 6 | 7 | help: 8 | @echo "usage:" 9 | @echo " make clean: remove all generated files (those ignored by git)" 10 | @echo " make $(MUNGED_DIR): create $(MUNGED_DIR) directory by applying the patch file to $(CONTRACTS_DIR)" 11 | @echo " make record: record a new patch file capturing the differences between $(CONTRACTS_DIR) and $(MUNGED_DIR)" 12 | 13 | munged: $(wildcard $(CONTRACTS_DIR)/*.sol) $(PATCH) 14 | rm -rf $@ 15 | cp -r $(CONTRACTS_DIR) $@ 16 | patch -p0 -d $@ < $(PATCH) 17 | 18 | record: 19 | diff -ruN $(CONTRACTS_DIR) $(MUNGED_DIR) | sed 's+../contracts/++g' | sed 's+munged/++g' > $(PATCH) 20 | 21 | clean: 22 | git clean -fdX 23 | touch $(PATCH) 24 | 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/harnesses/ERC20VotesHarness.sol: -------------------------------------------------------------------------------- 1 | import "../munged/token/ERC20/extensions/ERC20Votes.sol"; 2 | 3 | contract ERC20VotesHarness is ERC20Votes { 4 | constructor(string memory name, string memory symbol) ERC20Permit(name) ERC20(name, symbol) {} 5 | 6 | mapping(address => mapping(uint256 => uint256)) public _getPastVotes; 7 | 8 | function _afterTokenTransfer( 9 | address from, 10 | address to, 11 | uint256 amount 12 | ) internal virtual override { 13 | super._afterTokenTransfer(from, to, amount); 14 | _getPastVotes[from][block.number] -= amount; 15 | _getPastVotes[to][block.number] += amount; 16 | } 17 | 18 | /** 19 | * @dev Change delegation for `delegator` to `delegatee`. 20 | * 21 | * Emits events {DelegateChanged} and {DelegateVotesChanged}. 22 | */ 23 | function _delegate(address delegator, address delegatee) internal virtual override{ 24 | super._delegate(delegator, delegatee); 25 | _getPastVotes[delegator][block.number] -= balanceOf(delegator); 26 | _getPastVotes[delegatee][block.number] += balanceOf(delegator); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/munged/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/scripts/Governor.sh: -------------------------------------------------------------------------------- 1 | make -C certora munged 2 | 3 | certoraRun certora/harnesses/ERC20VotesHarness.sol certora/harnesses/GovernorHarness.sol \ 4 | --verify GovernorHarness:certora/specs/GovernorBase.spec \ 5 | --solc solc8.0 \ 6 | --staging shelly/forSasha \ 7 | --optimistic_loop \ 8 | --settings -copyLoopUnroll=4 \ 9 | --rule voteStartBeforeVoteEnd \ 10 | --msg "$1" 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/scripts/GovernorCountingSimple-counting.sh: -------------------------------------------------------------------------------- 1 | make -C certora munged 2 | 3 | certoraRun certora/harnesses/ERC20VotesHarness.sol certora/harnesses/GovernorBasicHarness.sol \ 4 | --verify GovernorBasicHarness:certora/specs/GovernorCountingSimple.spec \ 5 | --solc solc8.2 \ 6 | --staging shelly/forSasha \ 7 | --optimistic_loop \ 8 | --settings -copyLoopUnroll=4 \ 9 | --rule hasVotedCorrelation \ 10 | --msg "$1" 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/scripts/WizardControlFirstPriority.sh: -------------------------------------------------------------------------------- 1 | make -C certora munged 2 | 3 | certoraRun certora/harnesses/ERC20VotesHarness.sol certora/harnesses/WizardControlFirstPriority.sol \ 4 | --link WizardControlFirstPriority:token=ERC20VotesHarness \ 5 | --verify WizardControlFirstPriority:certora/specs/GovernorBase.spec \ 6 | --solc solc8.2 \ 7 | --disableLocalTypeChecking \ 8 | --staging shelly/forSasha \ 9 | --optimistic_loop \ 10 | --settings -copyLoopUnroll=4 \ 11 | --rule canVoteDuringVotingPeriod \ 12 | --msg "$1" 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/scripts/WizardFirstTry.sh: -------------------------------------------------------------------------------- 1 | make -C certora munged 2 | 3 | certoraRun certora/harnesses/ERC20VotesHarness.sol certora/harnesses/WizardFirstTry.sol \ 4 | --verify WizardFirstTry:certora/specs/GovernorBase.spec \ 5 | --solc solc8.2 \ 6 | --staging shelly/forSasha \ 7 | --optimistic_loop \ 8 | --disableLocalTypeChecking \ 9 | --settings -copyLoopUnroll=4 \ 10 | --msg "$1" 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/scripts/sanity.sh: -------------------------------------------------------------------------------- 1 | make -C certora munged 2 | 3 | for f in certora/harnesses/Wizard*.sol 4 | do 5 | echo "Processing $f" 6 | file=$(basename $f) 7 | echo ${file%.*} 8 | certoraRun certora/harnesses/$file \ 9 | --verify ${file%.*}:certora/specs/sanity.spec "$@" \ 10 | --solc solc8.2 --staging shelly/forSasha \ 11 | --optimistic_loop \ 12 | --msg "checking sanity on ${file%.*}" 13 | --settings -copyLoopUnroll=4 14 | done 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/scripts/verifyAll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | make -C certora munged 4 | 5 | for contract in certora/harnesses/Wizard*.sol; 6 | do 7 | for spec in certora/specs/*.spec; 8 | do 9 | contractFile=$(basename $contract) 10 | specFile=$(basename $spec) 11 | if [[ "${specFile%.*}" != "RulesInProgress" ]]; 12 | then 13 | echo "Processing ${contractFile%.*} with $specFile" 14 | if [[ "${contractFile%.*}" = *"WizardControl"* ]]; 15 | then 16 | certoraRun certora/harnesses/ERC20VotesHarness.sol certora/harnesses/$contractFile \ 17 | --link ${contractFile%.*}:token=ERC20VotesHarness \ 18 | --verify ${contractFile%.*}:certora/specs/$specFile "$@" \ 19 | --solc solc8.2 \ 20 | --staging shelly/forSasha \ 21 | --disableLocalTypeChecking \ 22 | --optimistic_loop \ 23 | --settings -copyLoopUnroll=4 \ 24 | --send_only \ 25 | --msg "checking $specFile on ${contractFile%.*}" 26 | else 27 | certoraRun certora/harnesses/ERC20VotesHarness.sol certora/harnesses/$contractFile \ 28 | --verify ${contractFile%.*}:certora/specs/$specFile "$@" \ 29 | --solc solc8.2 \ 30 | --staging shelly/forSasha \ 31 | --disableLocalTypeChecking \ 32 | --optimistic_loop \ 33 | --settings -copyLoopUnroll=4 \ 34 | --send_only \ 35 | --msg "checking $specFile on ${contractFile%.*}" 36 | fi 37 | fi 38 | done 39 | done 40 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/certora/specs/sanity.spec: -------------------------------------------------------------------------------- 1 | /* 2 | This rule looks for a non-reverting execution path to each method, including those overridden in the harness. 3 | A method has such an execution path if it violates this rule. 4 | How it works: 5 | - If there is a non-reverting execution path, we reach the false assertion, and the sanity fails. 6 | - If all execution paths are reverting, we never call the assertion, and the method will pass this rule vacuously. 7 | */ 8 | 9 | rule sanity(method f) { 10 | env e; 11 | calldataarg arg; 12 | f(e, arg); 13 | assert false; 14 | } -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/access/IAccessControlEnumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IAccessControl.sol"; 7 | 8 | /** 9 | * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. 10 | */ 11 | interface IAccessControlEnumerable is IAccessControl { 12 | /** 13 | * @dev Returns one of the accounts that have `role`. `index` must be a 14 | * value between 0 and {getRoleMemberCount}, non-inclusive. 15 | * 16 | * Role bearers are not sorted in any particular way, and their ordering may 17 | * change at any point. 18 | * 19 | * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure 20 | * you perform all queries on the same block. See the following 21 | * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] 22 | * for more information. 23 | */ 24 | function getRoleMember(bytes32 role, uint256 index) external view returns (address); 25 | 26 | /** 27 | * @dev Returns the number of accounts that have `role`. Can be used 28 | * together with {getRoleMember} to enumerate all bearers of a role. 29 | */ 30 | function getRoleMemberCount(bytes32 role) external view returns (uint256); 31 | } 32 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/access/README.adoc: -------------------------------------------------------------------------------- 1 | = Access Control 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/access 5 | 6 | This directory provides ways to restrict who can access the functions of a contract or when they can do it. 7 | 8 | - {AccessControl} provides a general role based access control mechanism. Multiple hierarchical roles can be created and assigned each to multiple accounts. 9 | - {Ownable} is a simpler mechanism with a single owner "role" that can be assigned to a single account. This simpler mechanism can be useful for quick tests but projects with production concerns are likely to outgrow it. 10 | 11 | == Authorization 12 | 13 | {{Ownable}} 14 | 15 | {{IAccessControl}} 16 | 17 | {{AccessControl}} 18 | 19 | {{IAccessControlEnumerable}} 20 | 21 | {{AccessControlEnumerable}} 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/finance/README.adoc: -------------------------------------------------------------------------------- 1 | = Finance 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/finance 5 | 6 | This directory includes primitives for financial systems: 7 | 8 | - {PaymentSplitter} allows to split Ether and ERC20 payments among a group of accounts. The sender does not need to be 9 | aware that the assets will be split in this way, since it is handled transparently by the contract. The split can be 10 | in equal parts or in any other arbitrary proportion. 11 | 12 | - {VestingWallet} handles the vesting of Ether and ERC20 tokens for a given beneficiary. Custody of multiple tokens can 13 | be given to this contract, which will release the token to the beneficiary following a given, customizable, vesting 14 | schedule. 15 | 16 | == Contracts 17 | 18 | {{PaymentSplitter}} 19 | 20 | {{VestingWallet}} 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/governance/extensions/GovernorProposalThreshold.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/GovernorProposalThreshold.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | 8 | /** 9 | * @dev Extension of {Governor} for proposal restriction to token holders with a minimum balance. 10 | * 11 | * _Available since v4.3._ 12 | * _Deprecated since v4.4._ 13 | */ 14 | abstract contract GovernorProposalThreshold is Governor { 15 | function propose( 16 | address[] memory targets, 17 | uint256[] memory values, 18 | bytes[] memory calldatas, 19 | string memory description 20 | ) public virtual override returns (uint256) { 21 | return super.propose(targets, values, calldatas, description); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/governance/extensions/GovernorVotes.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (governance/extensions/GovernorVotes.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | import "../utils/IVotes.sol"; 8 | 9 | /** 10 | * @dev Extension of {Governor} for voting weight extraction from an {ERC20Votes} token, or since v4.5 an {ERC721Votes} token. 11 | * 12 | * _Available since v4.3._ 13 | */ 14 | abstract contract GovernorVotes is Governor { 15 | IVotes public immutable token; 16 | 17 | constructor(IVotes tokenAddress) { 18 | token = tokenAddress; 19 | } 20 | 21 | /** 22 | * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}). 23 | */ 24 | function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) { 25 | return token.getPastVotes(account, blockNumber); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/governance/extensions/GovernorVotesComp.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/GovernorVotesComp.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Governor.sol"; 7 | import "../../token/ERC20/extensions/ERC20VotesComp.sol"; 8 | 9 | /** 10 | * @dev Extension of {Governor} for voting weight extraction from a Comp token. 11 | * 12 | * _Available since v4.3._ 13 | */ 14 | abstract contract GovernorVotesComp is Governor { 15 | ERC20VotesComp public immutable token; 16 | 17 | constructor(ERC20VotesComp token_) { 18 | token = token_; 19 | } 20 | 21 | /** 22 | * Read the voting weight from the token's built in snapshot mechanism (see {IGovernor-getVotes}). 23 | */ 24 | function getVotes(address account, uint256 blockNumber) public view virtual override returns (uint256) { 25 | return token.getPriorVotes(account, blockNumber); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/governance/extensions/IGovernorTimelock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (governance/extensions/IGovernorTimelock.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IGovernor.sol"; 7 | 8 | /** 9 | * @dev Extension of the {IGovernor} for timelock supporting modules. 10 | * 11 | * _Available since v4.3._ 12 | */ 13 | abstract contract IGovernorTimelock is IGovernor { 14 | event ProposalQueued(uint256 proposalId, uint256 eta); 15 | 16 | function timelock() public view virtual returns (address); 17 | 18 | function proposalEta(uint256 proposalId) public view virtual returns (uint256); 19 | 20 | function queue( 21 | address[] memory targets, 22 | uint256[] memory values, 23 | bytes[] memory calldatas, 24 | bytes32 descriptionHash 25 | ) public virtual returns (uint256 proposalId); 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1155.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/IERC1155.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155MetadataURI.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/extensions/IERC1155MetadataURI.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC1155/IERC1155Receiver.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1271.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC1271 standard signature validation method for 8 | * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. 9 | * 10 | * _Available since v4.1._ 11 | */ 12 | interface IERC1271 { 13 | /** 14 | * @dev Should return whether the signature provided is valid for the provided data 15 | * @param hash Hash of the data to be signed 16 | * @param signature Signature byte array associated with _data 17 | */ 18 | function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1363Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1363Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | interface IERC1363Receiver { 7 | /* 8 | * Note: the ERC-165 identifier for this interface is 0x88a7ca5c. 9 | * 0x88a7ca5c === bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)")) 10 | */ 11 | 12 | /** 13 | * @notice Handle the receipt of ERC1363 tokens 14 | * @dev Any ERC1363 smart contract calls this function on the recipient 15 | * after a `transfer` or a `transferFrom`. This function MAY throw to revert and reject the 16 | * transfer. Return of other than the magic value MUST result in the 17 | * transaction being reverted. 18 | * Note: the token contract address is always the message sender. 19 | * @param operator address The address which called `transferAndCall` or `transferFromAndCall` function 20 | * @param from address The address which are token transferred from 21 | * @param value uint256 The amount of tokens transferred 22 | * @param data bytes Additional data with no specified format 23 | * @return `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` 24 | * unless throwing 25 | */ 26 | function onTransferReceived( 27 | address operator, 28 | address from, 29 | uint256 value, 30 | bytes memory data 31 | ) external returns (bytes4); 32 | } 33 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1363Spender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1363Spender.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | interface IERC1363Spender { 7 | /* 8 | * Note: the ERC-165 identifier for this interface is 0x7b04a2d0. 9 | * 0x7b04a2d0 === bytes4(keccak256("onApprovalReceived(address,uint256,bytes)")) 10 | */ 11 | 12 | /** 13 | * @notice Handle the approval of ERC1363 tokens 14 | * @dev Any ERC1363 smart contract calls this function on the recipient 15 | * after an `approve`. This function MAY throw to revert and reject the 16 | * approval. Return of other than the magic value MUST result in the 17 | * transaction being reverted. 18 | * Note: the token contract address is always the message sender. 19 | * @param owner address The address which called `approveAndCall` function 20 | * @param value uint256 The amount of tokens to be spent 21 | * @param data bytes Additional data with no specified format 22 | * @return `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))` 23 | * unless throwing 24 | */ 25 | function onApprovalReceived( 26 | address owner, 27 | uint256 value, 28 | bytes memory data 29 | ) external returns (bytes4); 30 | } 31 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC165.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC1820Implementer.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC1820Registry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1820Registry.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../utils/introspection/IERC1820Registry.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/IERC20.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC20Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/extensions/IERC20Metadata.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/IERC2981.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC165.sol"; 7 | 8 | /** 9 | * @dev Interface for the NFT Royalty Standard. 10 | * 11 | * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal 12 | * support for royalty payments across all NFT marketplaces and ecosystem participants. 13 | * 14 | * _Available since v4.5._ 15 | */ 16 | interface IERC2981 is IERC165 { 17 | /** 18 | * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of 19 | * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. 20 | */ 21 | function royaltyInfo(uint256 tokenId, uint256 salePrice) 22 | external 23 | view 24 | returns (address receiver, uint256 royaltyAmount); 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC3156.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC3156FlashBorrower.sol"; 7 | import "./IERC3156FlashLender.sol"; 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC3156FlashBorrower.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashBorrower.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC3156 FlashBorrower, as defined in 8 | * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156]. 9 | * 10 | * _Available since v4.1._ 11 | */ 12 | interface IERC3156FlashBorrower { 13 | /** 14 | * @dev Receive a flash loan. 15 | * @param initiator The initiator of the loan. 16 | * @param token The loan currency. 17 | * @param amount The amount of tokens lent. 18 | * @param fee The additional amount of tokens to repay. 19 | * @param data Arbitrary data structure, intended to contain user-defined parameters. 20 | * @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan" 21 | */ 22 | function onFlashLoan( 23 | address initiator, 24 | address token, 25 | uint256 amount, 26 | uint256 fee, 27 | bytes calldata data 28 | ) external returns (bytes32); 29 | } 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC3156FlashLender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC3156FlashLender.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC3156FlashBorrower.sol"; 7 | 8 | /** 9 | * @dev Interface of the ERC3156 FlashLender, as defined in 10 | * https://eips.ethereum.org/EIPS/eip-3156[ERC-3156]. 11 | * 12 | * _Available since v4.1._ 13 | */ 14 | interface IERC3156FlashLender { 15 | /** 16 | * @dev The amount of currency available to be lended. 17 | * @param token The loan currency. 18 | * @return The amount of `token` that can be borrowed. 19 | */ 20 | function maxFlashLoan(address token) external view returns (uint256); 21 | 22 | /** 23 | * @dev The fee to be charged for a given loan. 24 | * @param token The loan currency. 25 | * @param amount The amount of tokens lent. 26 | * @return The amount of `token` to be charged for the loan, on top of the returned principal. 27 | */ 28 | function flashFee(address token, uint256 amount) external view returns (uint256); 29 | 30 | /** 31 | * @dev Initiate a flash loan. 32 | * @param receiver The receiver of the tokens in the loan, and the receiver of the callback. 33 | * @param token The loan currency. 34 | * @param amount The amount of tokens lent. 35 | * @param data Arbitrary data structure, intended to contain user-defined parameters. 36 | */ 37 | function flashLoan( 38 | IERC3156FlashBorrower receiver, 39 | address token, 40 | uint256 amount, 41 | bytes calldata data 42 | ) external returns (bool); 43 | } 44 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/IERC721.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721Enumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/extensions/IERC721Enumerable.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/extensions/IERC721Metadata.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC721/IERC721Receiver.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC777.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC777Recipient.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Recipient.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777Recipient.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/IERC777Sender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Sender.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC777/IERC777Sender.sol"; 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/README.adoc: -------------------------------------------------------------------------------- 1 | = Interfaces 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/interfaces 5 | 6 | == List of standardized interfaces 7 | These interfaces are available as `.sol` files, and also as compiler `.json` ABI files (through the npm package). These 8 | are useful to interact with third party contracts that implement them. 9 | 10 | - {IERC20} 11 | - {IERC20Metadata} 12 | - {IERC165} 13 | - {IERC721} 14 | - {IERC721Receiver} 15 | - {IERC721Enumerable} 16 | - {IERC721Metadata} 17 | - {IERC777} 18 | - {IERC777Recipient} 19 | - {IERC777Sender} 20 | - {IERC1155} 21 | - {IERC1155Receiver} 22 | - {IERC1155MetadataURI} 23 | - {IERC1271} 24 | - {IERC1363} 25 | - {IERC1820Implementer} 26 | - {IERC1820Registry} 27 | - {IERC2612} 28 | - {IERC2981} 29 | - {IERC3156FlashLender} 30 | - {IERC3156FlashBorrower} 31 | 32 | == Detailed ABI 33 | 34 | {{IERC1271}} 35 | 36 | {{IERC1363}} 37 | 38 | {{IERC1363Receiver}} 39 | 40 | {{IERC1820Implementer}} 41 | 42 | {{IERC1820Registry}} 43 | 44 | {{IERC2612}} 45 | 46 | {{IERC2981}} 47 | 48 | {{IERC3156FlashLender}} 49 | 50 | {{IERC3156FlashBorrower}} 51 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified 8 | * proxy whose upgrades are fully controlled by the current implementation. 9 | */ 10 | interface IERC1822Proxiable { 11 | /** 12 | * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation 13 | * address. 14 | * 15 | * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks 16 | * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this 17 | * function revert if invoked through a proxy. 18 | */ 19 | function proxiableUUID() external view returns (bytes32); 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/interfaces/draft-IERC2612.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (interfaces/draft-IERC2612.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../token/ERC20/extensions/draft-IERC20Permit.sol"; 7 | 8 | interface IERC2612 is IERC20Permit {} 9 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/metatx/ERC2771Context.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (metatx/ERC2771Context.sol) 3 | 4 | pragma solidity ^0.8.9; 5 | 6 | import "../utils/Context.sol"; 7 | 8 | /** 9 | * @dev Context variant with ERC2771 support. 10 | */ 11 | abstract contract ERC2771Context is Context { 12 | /// @custom:oz-upgrades-unsafe-allow state-variable-immutable 13 | address private immutable _trustedForwarder; 14 | 15 | /// @custom:oz-upgrades-unsafe-allow constructor 16 | constructor(address trustedForwarder) { 17 | _trustedForwarder = trustedForwarder; 18 | } 19 | 20 | function isTrustedForwarder(address forwarder) public view virtual returns (bool) { 21 | return forwarder == _trustedForwarder; 22 | } 23 | 24 | function _msgSender() internal view virtual override returns (address sender) { 25 | if (isTrustedForwarder(msg.sender)) { 26 | // The assembly code is more direct than the Solidity version using `abi.decode`. 27 | assembly { 28 | sender := shr(96, calldataload(sub(calldatasize(), 20))) 29 | } 30 | } else { 31 | return super._msgSender(); 32 | } 33 | } 34 | 35 | function _msgData() internal view virtual override returns (bytes calldata) { 36 | if (isTrustedForwarder(msg.sender)) { 37 | return msg.data[:msg.data.length - 20]; 38 | } else { 39 | return super._msgData(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/metatx/README.adoc: -------------------------------------------------------------------------------- 1 | = Meta Transactions 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/metatx 5 | 6 | == Core 7 | 8 | {{ERC2771Context}} 9 | 10 | == Utils 11 | 12 | {{MinimalForwarder}} 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/AccessControlEnumerableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../access/AccessControlEnumerable.sol"; 6 | 7 | contract AccessControlEnumerableMock is AccessControlEnumerable { 8 | constructor() { 9 | _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); 10 | } 11 | 12 | function setRoleAdmin(bytes32 roleId, bytes32 adminRoleId) public { 13 | _setRoleAdmin(roleId, adminRoleId); 14 | } 15 | 16 | function senderProtected(bytes32 roleId) public onlyRole(roleId) {} 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/AccessControlMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../access/AccessControl.sol"; 6 | 7 | contract AccessControlMock is AccessControl { 8 | constructor() { 9 | _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); 10 | } 11 | 12 | function setRoleAdmin(bytes32 roleId, bytes32 adminRoleId) public { 13 | _setRoleAdmin(roleId, adminRoleId); 14 | } 15 | 16 | function senderProtected(bytes32 roleId) public onlyRole(roleId) {} 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ArraysImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Arrays.sol"; 6 | 7 | contract ArraysImpl { 8 | using Arrays for uint256[]; 9 | 10 | uint256[] private _array; 11 | 12 | constructor(uint256[] memory array) { 13 | _array = array; 14 | } 15 | 16 | function findUpperBound(uint256 element) external view returns (uint256) { 17 | return _array.findUpperBound(element); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/BadBeacon.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract BadBeaconNoImpl {} 6 | 7 | contract BadBeaconNotContract { 8 | function implementation() external pure returns (address) { 9 | return address(0x1); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/Base64Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Base64.sol"; 6 | 7 | contract Base64Mock { 8 | function encode(bytes memory value) external pure returns (string memory) { 9 | return Base64.encode(value); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/BitmapMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/structs/BitMaps.sol"; 6 | 7 | contract BitMapMock { 8 | using BitMaps for BitMaps.BitMap; 9 | 10 | BitMaps.BitMap private _bitmap; 11 | 12 | function get(uint256 index) public view returns (bool) { 13 | return _bitmap.get(index); 14 | } 15 | 16 | function setTo(uint256 index, bool value) public { 17 | _bitmap.setTo(index, value); 18 | } 19 | 20 | function set(uint256 index) public { 21 | _bitmap.set(index); 22 | } 23 | 24 | function unset(uint256 index) public { 25 | _bitmap.unset(index); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/CallReceiverMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract CallReceiverMock { 6 | string public sharedAnswer; 7 | 8 | event MockFunctionCalled(); 9 | event MockFunctionCalledWithArgs(uint256 a, uint256 b); 10 | 11 | uint256[] private _array; 12 | 13 | function mockFunction() public payable returns (string memory) { 14 | emit MockFunctionCalled(); 15 | 16 | return "0x1234"; 17 | } 18 | 19 | function mockFunctionWithArgs(uint256 a, uint256 b) public payable returns (string memory) { 20 | emit MockFunctionCalledWithArgs(a, b); 21 | 22 | return "0x1234"; 23 | } 24 | 25 | function mockFunctionNonPayable() public returns (string memory) { 26 | emit MockFunctionCalled(); 27 | 28 | return "0x1234"; 29 | } 30 | 31 | function mockStaticFunction() public pure returns (string memory) { 32 | return "0x1234"; 33 | } 34 | 35 | function mockFunctionRevertsNoReason() public payable { 36 | revert(); 37 | } 38 | 39 | function mockFunctionRevertsReason() public payable { 40 | revert("CallReceiverMock: reverting"); 41 | } 42 | 43 | function mockFunctionThrows() public payable { 44 | assert(false); 45 | } 46 | 47 | function mockFunctionOutOfGas() public payable { 48 | for (uint256 i = 0; ; ++i) { 49 | _array.push(i); 50 | } 51 | } 52 | 53 | function mockFunctionWritesStorage() public returns (string memory) { 54 | sharedAnswer = "42"; 55 | return "0x1234"; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/CheckpointsImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Checkpoints.sol"; 6 | 7 | contract CheckpointsImpl { 8 | using Checkpoints for Checkpoints.History; 9 | 10 | Checkpoints.History private _totalCheckpoints; 11 | 12 | function latest() public view returns (uint256) { 13 | return _totalCheckpoints.latest(); 14 | } 15 | 16 | function getAtBlock(uint256 blockNumber) public view returns (uint256) { 17 | return _totalCheckpoints.getAtBlock(blockNumber); 18 | } 19 | 20 | function push(uint256 value) public returns (uint256, uint256) { 21 | return _totalCheckpoints.push(value); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ClashingImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | /** 6 | * @dev Implementation contract with an admin() function made to clash with 7 | * @dev TransparentUpgradeableProxy's to test correct functioning of the 8 | * @dev Transparent Proxy feature. 9 | */ 10 | contract ClashingImplementation { 11 | function admin() external pure returns (address) { 12 | return 0x0000000000000000000000000000000011111142; 13 | } 14 | 15 | function delegatedFunction() external pure returns (bool) { 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ClonesMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../proxy/Clones.sol"; 6 | import "../utils/Address.sol"; 7 | 8 | contract ClonesMock { 9 | using Address for address; 10 | using Clones for address; 11 | 12 | event NewInstance(address instance); 13 | 14 | function clone(address implementation, bytes calldata initdata) public payable { 15 | _initAndEmit(implementation.clone(), initdata); 16 | } 17 | 18 | function cloneDeterministic( 19 | address implementation, 20 | bytes32 salt, 21 | bytes calldata initdata 22 | ) public payable { 23 | _initAndEmit(implementation.cloneDeterministic(salt), initdata); 24 | } 25 | 26 | function predictDeterministicAddress(address implementation, bytes32 salt) public view returns (address predicted) { 27 | return implementation.predictDeterministicAddress(salt); 28 | } 29 | 30 | function _initAndEmit(address instance, bytes memory initdata) private { 31 | if (initdata.length > 0) { 32 | instance.functionCallWithValue(initdata, msg.value); 33 | } 34 | emit NewInstance(instance); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ConditionalEscrowMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/escrow/ConditionalEscrow.sol"; 6 | 7 | // mock class using ConditionalEscrow 8 | contract ConditionalEscrowMock is ConditionalEscrow { 9 | mapping(address => bool) private _allowed; 10 | 11 | function setAllowed(address payee, bool allowed) public { 12 | _allowed[payee] = allowed; 13 | } 14 | 15 | function withdrawalAllowed(address payee) public view override returns (bool) { 16 | return _allowed[payee]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ContextMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Context.sol"; 6 | 7 | contract ContextMock is Context { 8 | event Sender(address sender); 9 | 10 | function msgSender() public { 11 | emit Sender(_msgSender()); 12 | } 13 | 14 | event Data(bytes data, uint256 integerValue, string stringValue); 15 | 16 | function msgData(uint256 integerValue, string memory stringValue) public { 17 | emit Data(_msgData(), integerValue, stringValue); 18 | } 19 | } 20 | 21 | contract ContextMockCaller { 22 | function callSender(ContextMock context) public { 23 | context.msgSender(); 24 | } 25 | 26 | function callData( 27 | ContextMock context, 28 | uint256 integerValue, 29 | string memory stringValue 30 | ) public { 31 | context.msgData(integerValue, stringValue); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/CountersImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Counters.sol"; 6 | 7 | contract CountersImpl { 8 | using Counters for Counters.Counter; 9 | 10 | Counters.Counter private _counter; 11 | 12 | function current() public view returns (uint256) { 13 | return _counter.current(); 14 | } 15 | 16 | function increment() public { 17 | _counter.increment(); 18 | } 19 | 20 | function decrement() public { 21 | _counter.decrement(); 22 | } 23 | 24 | function reset() public { 25 | _counter.reset(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/Create2Impl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Create2.sol"; 6 | import "../utils/introspection/ERC1820Implementer.sol"; 7 | 8 | contract Create2Impl { 9 | function deploy( 10 | uint256 value, 11 | bytes32 salt, 12 | bytes memory code 13 | ) public { 14 | Create2.deploy(value, salt, code); 15 | } 16 | 17 | function deployERC1820Implementer(uint256 value, bytes32 salt) public { 18 | Create2.deploy(value, salt, type(ERC1820Implementer).creationCode); 19 | } 20 | 21 | function computeAddress(bytes32 salt, bytes32 codeHash) public view returns (address) { 22 | return Create2.computeAddress(salt, codeHash); 23 | } 24 | 25 | function computeAddressWithDeployer( 26 | bytes32 salt, 27 | bytes32 codeHash, 28 | address deployer 29 | ) public pure returns (address) { 30 | return Create2.computeAddress(salt, codeHash, deployer); 31 | } 32 | 33 | receive() external payable {} 34 | } 35 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/DummyImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | abstract contract Impl { 6 | function version() public pure virtual returns (string memory); 7 | } 8 | 9 | contract DummyImplementation { 10 | uint256 public value; 11 | string public text; 12 | uint256[] public values; 13 | 14 | function initializeNonPayable() public { 15 | value = 10; 16 | } 17 | 18 | function initializePayable() public payable { 19 | value = 100; 20 | } 21 | 22 | function initializeNonPayableWithValue(uint256 _value) public { 23 | value = _value; 24 | } 25 | 26 | function initializePayableWithValue(uint256 _value) public payable { 27 | value = _value; 28 | } 29 | 30 | function initialize( 31 | uint256 _value, 32 | string memory _text, 33 | uint256[] memory _values 34 | ) public { 35 | value = _value; 36 | text = _text; 37 | values = _values; 38 | } 39 | 40 | function get() public pure returns (bool) { 41 | return true; 42 | } 43 | 44 | function version() public pure virtual returns (string memory) { 45 | return "V1"; 46 | } 47 | 48 | function reverts() public pure { 49 | require(false, "DummyImplementation reverted"); 50 | } 51 | } 52 | 53 | contract DummyImplementationV2 is DummyImplementation { 54 | function migrate(uint256 newVal) public payable { 55 | value = newVal; 56 | } 57 | 58 | function version() public pure override returns (string memory) { 59 | return "V2"; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ECDSAMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/cryptography/ECDSA.sol"; 6 | 7 | contract ECDSAMock { 8 | using ECDSA for bytes32; 9 | using ECDSA for bytes; 10 | 11 | function recover(bytes32 hash, bytes memory signature) public pure returns (address) { 12 | return hash.recover(signature); 13 | } 14 | 15 | // solhint-disable-next-line func-name-mixedcase 16 | function recover_v_r_s( 17 | bytes32 hash, 18 | uint8 v, 19 | bytes32 r, 20 | bytes32 s 21 | ) public pure returns (address) { 22 | return hash.recover(v, r, s); 23 | } 24 | 25 | // solhint-disable-next-line func-name-mixedcase 26 | function recover_r_vs( 27 | bytes32 hash, 28 | bytes32 r, 29 | bytes32 vs 30 | ) public pure returns (address) { 31 | return hash.recover(r, vs); 32 | } 33 | 34 | function toEthSignedMessageHash(bytes32 hash) public pure returns (bytes32) { 35 | return hash.toEthSignedMessageHash(); 36 | } 37 | 38 | function toEthSignedMessageHash(bytes memory s) public pure returns (bytes32) { 39 | return s.toEthSignedMessageHash(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/EIP712External.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/cryptography/draft-EIP712.sol"; 6 | import "../utils/cryptography/ECDSA.sol"; 7 | 8 | contract EIP712External is EIP712 { 9 | constructor(string memory name, string memory version) EIP712(name, version) {} 10 | 11 | function domainSeparator() external view returns (bytes32) { 12 | return _domainSeparatorV4(); 13 | } 14 | 15 | function verify( 16 | bytes memory signature, 17 | address signer, 18 | address mailTo, 19 | string memory mailContents 20 | ) external view { 21 | bytes32 digest = _hashTypedDataV4( 22 | keccak256(abi.encode(keccak256("Mail(address to,string contents)"), mailTo, keccak256(bytes(mailContents)))) 23 | ); 24 | address recoveredSigner = ECDSA.recover(digest, signature); 25 | require(recoveredSigner == signer); 26 | } 27 | 28 | function getChainId() external view returns (uint256) { 29 | return block.chainid; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1155BurnableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC1155/extensions/ERC1155Burnable.sol"; 6 | 7 | contract ERC1155BurnableMock is ERC1155Burnable { 8 | constructor(string memory uri) ERC1155(uri) {} 9 | 10 | function mint( 11 | address to, 12 | uint256 id, 13 | uint256 value, 14 | bytes memory data 15 | ) public { 16 | _mint(to, id, value, data); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1155Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC1155/ERC1155.sol"; 6 | 7 | /** 8 | * @title ERC1155Mock 9 | * This mock just publicizes internal functions for testing purposes 10 | */ 11 | contract ERC1155Mock is ERC1155 { 12 | constructor(string memory uri) ERC1155(uri) {} 13 | 14 | function setURI(string memory newuri) public { 15 | _setURI(newuri); 16 | } 17 | 18 | function mint( 19 | address to, 20 | uint256 id, 21 | uint256 value, 22 | bytes memory data 23 | ) public { 24 | _mint(to, id, value, data); 25 | } 26 | 27 | function mintBatch( 28 | address to, 29 | uint256[] memory ids, 30 | uint256[] memory values, 31 | bytes memory data 32 | ) public { 33 | _mintBatch(to, ids, values, data); 34 | } 35 | 36 | function burn( 37 | address owner, 38 | uint256 id, 39 | uint256 value 40 | ) public { 41 | _burn(owner, id, value); 42 | } 43 | 44 | function burnBatch( 45 | address owner, 46 | uint256[] memory ids, 47 | uint256[] memory values 48 | ) public { 49 | _burnBatch(owner, ids, values); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1155PausableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "./ERC1155Mock.sol"; 6 | import "../token/ERC1155/extensions/ERC1155Pausable.sol"; 7 | 8 | contract ERC1155PausableMock is ERC1155Mock, ERC1155Pausable { 9 | constructor(string memory uri) ERC1155Mock(uri) {} 10 | 11 | function pause() external { 12 | _pause(); 13 | } 14 | 15 | function unpause() external { 16 | _unpause(); 17 | } 18 | 19 | function _beforeTokenTransfer( 20 | address operator, 21 | address from, 22 | address to, 23 | uint256[] memory ids, 24 | uint256[] memory amounts, 25 | bytes memory data 26 | ) internal virtual override(ERC1155, ERC1155Pausable) { 27 | super._beforeTokenTransfer(operator, from, to, ids, amounts, data); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1155SupplyMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "./ERC1155Mock.sol"; 6 | import "../token/ERC1155/extensions/ERC1155Supply.sol"; 7 | 8 | contract ERC1155SupplyMock is ERC1155Mock, ERC1155Supply { 9 | constructor(string memory uri) ERC1155Mock(uri) {} 10 | 11 | function _beforeTokenTransfer( 12 | address operator, 13 | address from, 14 | address to, 15 | uint256[] memory ids, 16 | uint256[] memory amounts, 17 | bytes memory data 18 | ) internal virtual override(ERC1155, ERC1155Supply) { 19 | super._beforeTokenTransfer(operator, from, to, ids, amounts, data); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1271WalletMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../access/Ownable.sol"; 6 | import "../interfaces/IERC1271.sol"; 7 | import "../utils/cryptography/ECDSA.sol"; 8 | 9 | contract ERC1271WalletMock is Ownable, IERC1271 { 10 | constructor(address originalOwner) { 11 | transferOwnership(originalOwner); 12 | } 13 | 14 | function isValidSignature(bytes32 hash, bytes memory signature) public view override returns (bytes4 magicValue) { 15 | return ECDSA.recover(hash, signature) == owner() ? this.isValidSignature.selector : bytes4(0); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165/ERC165MissingData.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract ERC165MissingData { 6 | function supportsInterface(bytes4 interfaceId) public view {} // missing return 7 | } 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165/ERC165NotSupported.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract ERC165NotSupported {} 6 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165CheckerMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/introspection/ERC165Checker.sol"; 6 | 7 | contract ERC165CheckerMock { 8 | using ERC165Checker for address; 9 | 10 | function supportsERC165(address account) public view returns (bool) { 11 | return account.supportsERC165(); 12 | } 13 | 14 | function supportsInterface(address account, bytes4 interfaceId) public view returns (bool) { 15 | return account.supportsInterface(interfaceId); 16 | } 17 | 18 | function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) { 19 | return account.supportsAllInterfaces(interfaceIds); 20 | } 21 | 22 | function getSupportedInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool[] memory) { 23 | return account.getSupportedInterfaces(interfaceIds); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/introspection/ERC165.sol"; 6 | 7 | contract ERC165Mock is ERC165 {} 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC165StorageMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/introspection/ERC165Storage.sol"; 6 | 7 | contract ERC165StorageMock is ERC165Storage { 8 | function registerInterface(bytes4 interfaceId) public { 9 | _registerInterface(interfaceId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC1820ImplementerMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/introspection/ERC1820Implementer.sol"; 6 | 7 | contract ERC1820ImplementerMock is ERC1820Implementer { 8 | function registerInterfaceForAddress(bytes32 interfaceHash, address account) public { 9 | _registerInterfaceForAddress(interfaceHash, account); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20BurnableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20Burnable.sol"; 6 | 7 | contract ERC20BurnableMock is ERC20Burnable { 8 | constructor( 9 | string memory name, 10 | string memory symbol, 11 | address initialAccount, 12 | uint256 initialBalance 13 | ) ERC20(name, symbol) { 14 | _mint(initialAccount, initialBalance); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20CappedMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20Capped.sol"; 6 | 7 | contract ERC20CappedMock is ERC20Capped { 8 | constructor( 9 | string memory name, 10 | string memory symbol, 11 | uint256 cap 12 | ) ERC20(name, symbol) ERC20Capped(cap) {} 13 | 14 | function mint(address to, uint256 tokenId) public { 15 | _mint(to, tokenId); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20DecimalsMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/ERC20.sol"; 6 | 7 | contract ERC20DecimalsMock is ERC20 { 8 | uint8 private immutable _decimals; 9 | 10 | constructor( 11 | string memory name_, 12 | string memory symbol_, 13 | uint8 decimals_ 14 | ) ERC20(name_, symbol_) { 15 | _decimals = decimals_; 16 | } 17 | 18 | function decimals() public view virtual override returns (uint8) { 19 | return _decimals; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20FlashMintMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20FlashMint.sol"; 6 | 7 | contract ERC20FlashMintMock is ERC20FlashMint { 8 | constructor( 9 | string memory name, 10 | string memory symbol, 11 | address initialAccount, 12 | uint256 initialBalance 13 | ) ERC20(name, symbol) { 14 | _mint(initialAccount, initialBalance); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/ERC20.sol"; 6 | 7 | // mock class using ERC20 8 | contract ERC20Mock is ERC20 { 9 | constructor( 10 | string memory name, 11 | string memory symbol, 12 | address initialAccount, 13 | uint256 initialBalance 14 | ) payable ERC20(name, symbol) { 15 | _mint(initialAccount, initialBalance); 16 | } 17 | 18 | function mint(address account, uint256 amount) public { 19 | _mint(account, amount); 20 | } 21 | 22 | function burn(address account, uint256 amount) public { 23 | _burn(account, amount); 24 | } 25 | 26 | function transferInternal( 27 | address from, 28 | address to, 29 | uint256 value 30 | ) public { 31 | _transfer(from, to, value); 32 | } 33 | 34 | function approveInternal( 35 | address owner, 36 | address spender, 37 | uint256 value 38 | ) public { 39 | _approve(owner, spender, value); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20PausableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20Pausable.sol"; 6 | 7 | // mock class using ERC20Pausable 8 | contract ERC20PausableMock is ERC20Pausable { 9 | constructor( 10 | string memory name, 11 | string memory symbol, 12 | address initialAccount, 13 | uint256 initialBalance 14 | ) ERC20(name, symbol) { 15 | _mint(initialAccount, initialBalance); 16 | } 17 | 18 | function pause() external { 19 | _pause(); 20 | } 21 | 22 | function unpause() external { 23 | _unpause(); 24 | } 25 | 26 | function mint(address to, uint256 amount) public { 27 | _mint(to, amount); 28 | } 29 | 30 | function burn(address from, uint256 amount) public { 31 | _burn(from, amount); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20PermitMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/draft-ERC20Permit.sol"; 6 | 7 | contract ERC20PermitMock is ERC20Permit { 8 | constructor( 9 | string memory name, 10 | string memory symbol, 11 | address initialAccount, 12 | uint256 initialBalance 13 | ) payable ERC20(name, symbol) ERC20Permit(name) { 14 | _mint(initialAccount, initialBalance); 15 | } 16 | 17 | function getChainId() external view returns (uint256) { 18 | return block.chainid; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20SnapshotMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20Snapshot.sol"; 6 | 7 | contract ERC20SnapshotMock is ERC20Snapshot { 8 | constructor( 9 | string memory name, 10 | string memory symbol, 11 | address initialAccount, 12 | uint256 initialBalance 13 | ) ERC20(name, symbol) { 14 | _mint(initialAccount, initialBalance); 15 | } 16 | 17 | function snapshot() public { 18 | _snapshot(); 19 | } 20 | 21 | function mint(address account, uint256 amount) public { 22 | _mint(account, amount); 23 | } 24 | 25 | function burn(address account, uint256 amount) public { 26 | _burn(account, amount); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20VotesCompMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20VotesComp.sol"; 6 | 7 | contract ERC20VotesCompMock is ERC20VotesComp { 8 | constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {} 9 | 10 | function mint(address account, uint256 amount) public { 11 | _mint(account, amount); 12 | } 13 | 14 | function burn(address account, uint256 amount) public { 15 | _burn(account, amount); 16 | } 17 | 18 | function getChainId() external view returns (uint256) { 19 | return block.chainid; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20VotesMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20Votes.sol"; 6 | 7 | contract ERC20VotesMock is ERC20Votes { 8 | constructor(string memory name, string memory symbol) ERC20(name, symbol) ERC20Permit(name) {} 9 | 10 | function mint(address account, uint256 amount) public { 11 | _mint(account, amount); 12 | } 13 | 14 | function burn(address account, uint256 amount) public { 15 | _burn(account, amount); 16 | } 17 | 18 | function getChainId() external view returns (uint256) { 19 | return block.chainid; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC20WrapperMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC20/extensions/ERC20Wrapper.sol"; 6 | 7 | contract ERC20WrapperMock is ERC20Wrapper { 8 | constructor( 9 | IERC20 _underlyingToken, 10 | string memory name, 11 | string memory symbol 12 | ) ERC20(name, symbol) ERC20Wrapper(_underlyingToken) {} 13 | 14 | function recover(address account) public returns (uint256) { 15 | return _recover(account); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC2771ContextMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.9; 4 | 5 | import "./ContextMock.sol"; 6 | import "../metatx/ERC2771Context.sol"; 7 | 8 | // By inheriting from ERC2771Context, Context's internal functions are overridden automatically 9 | contract ERC2771ContextMock is ContextMock, ERC2771Context { 10 | /// @custom:oz-upgrades-unsafe-allow constructor 11 | constructor(address trustedForwarder) ERC2771Context(trustedForwarder) { 12 | emit Sender(_msgSender()); // _msgSender() should be accessible during construction 13 | } 14 | 15 | function _msgSender() internal view virtual override(Context, ERC2771Context) returns (address) { 16 | return ERC2771Context._msgSender(); 17 | } 18 | 19 | function _msgData() internal view virtual override(Context, ERC2771Context) returns (bytes calldata) { 20 | return ERC2771Context._msgData(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721BurnableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/extensions/ERC721Burnable.sol"; 6 | 7 | contract ERC721BurnableMock is ERC721Burnable { 8 | constructor(string memory name, string memory symbol) ERC721(name, symbol) {} 9 | 10 | function exists(uint256 tokenId) public view returns (bool) { 11 | return _exists(tokenId); 12 | } 13 | 14 | function mint(address to, uint256 tokenId) public { 15 | _mint(to, tokenId); 16 | } 17 | 18 | function safeMint(address to, uint256 tokenId) public { 19 | _safeMint(to, tokenId); 20 | } 21 | 22 | function safeMint( 23 | address to, 24 | uint256 tokenId, 25 | bytes memory _data 26 | ) public { 27 | _safeMint(to, tokenId, _data); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721EnumerableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/extensions/ERC721Enumerable.sol"; 6 | 7 | /** 8 | * @title ERC721Mock 9 | * This mock just provides a public safeMint, mint, and burn functions for testing purposes 10 | */ 11 | contract ERC721EnumerableMock is ERC721Enumerable { 12 | string private _baseTokenURI; 13 | 14 | constructor(string memory name, string memory symbol) ERC721(name, symbol) {} 15 | 16 | function _baseURI() internal view virtual override returns (string memory) { 17 | return _baseTokenURI; 18 | } 19 | 20 | function setBaseURI(string calldata newBaseTokenURI) public { 21 | _baseTokenURI = newBaseTokenURI; 22 | } 23 | 24 | function baseURI() public view returns (string memory) { 25 | return _baseURI(); 26 | } 27 | 28 | function exists(uint256 tokenId) public view returns (bool) { 29 | return _exists(tokenId); 30 | } 31 | 32 | function mint(address to, uint256 tokenId) public { 33 | _mint(to, tokenId); 34 | } 35 | 36 | function safeMint(address to, uint256 tokenId) public { 37 | _safeMint(to, tokenId); 38 | } 39 | 40 | function safeMint( 41 | address to, 42 | uint256 tokenId, 43 | bytes memory _data 44 | ) public { 45 | _safeMint(to, tokenId, _data); 46 | } 47 | 48 | function burn(uint256 tokenId) public { 49 | _burn(tokenId); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/ERC721.sol"; 6 | 7 | /** 8 | * @title ERC721Mock 9 | * This mock just provides a public safeMint, mint, and burn functions for testing purposes 10 | */ 11 | contract ERC721Mock is ERC721 { 12 | constructor(string memory name, string memory symbol) ERC721(name, symbol) {} 13 | 14 | function baseURI() public view returns (string memory) { 15 | return _baseURI(); 16 | } 17 | 18 | function exists(uint256 tokenId) public view returns (bool) { 19 | return _exists(tokenId); 20 | } 21 | 22 | function mint(address to, uint256 tokenId) public { 23 | _mint(to, tokenId); 24 | } 25 | 26 | function safeMint(address to, uint256 tokenId) public { 27 | _safeMint(to, tokenId); 28 | } 29 | 30 | function safeMint( 31 | address to, 32 | uint256 tokenId, 33 | bytes memory _data 34 | ) public { 35 | _safeMint(to, tokenId, _data); 36 | } 37 | 38 | function burn(uint256 tokenId) public { 39 | _burn(tokenId); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721PausableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/extensions/ERC721Pausable.sol"; 6 | 7 | /** 8 | * @title ERC721PausableMock 9 | * This mock just provides a public mint, burn and exists functions for testing purposes 10 | */ 11 | contract ERC721PausableMock is ERC721Pausable { 12 | constructor(string memory name, string memory symbol) ERC721(name, symbol) {} 13 | 14 | function pause() external { 15 | _pause(); 16 | } 17 | 18 | function unpause() external { 19 | _unpause(); 20 | } 21 | 22 | function exists(uint256 tokenId) public view returns (bool) { 23 | return _exists(tokenId); 24 | } 25 | 26 | function mint(address to, uint256 tokenId) public { 27 | _mint(to, tokenId); 28 | } 29 | 30 | function safeMint(address to, uint256 tokenId) public { 31 | _safeMint(to, tokenId); 32 | } 33 | 34 | function safeMint( 35 | address to, 36 | uint256 tokenId, 37 | bytes memory _data 38 | ) public { 39 | _safeMint(to, tokenId, _data); 40 | } 41 | 42 | function burn(uint256 tokenId) public { 43 | _burn(tokenId); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721ReceiverMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/IERC721Receiver.sol"; 6 | 7 | contract ERC721ReceiverMock is IERC721Receiver { 8 | enum Error { 9 | None, 10 | RevertWithMessage, 11 | RevertWithoutMessage, 12 | Panic 13 | } 14 | 15 | bytes4 private immutable _retval; 16 | Error private immutable _error; 17 | 18 | event Received(address operator, address from, uint256 tokenId, bytes data, uint256 gas); 19 | 20 | constructor(bytes4 retval, Error error) { 21 | _retval = retval; 22 | _error = error; 23 | } 24 | 25 | function onERC721Received( 26 | address operator, 27 | address from, 28 | uint256 tokenId, 29 | bytes memory data 30 | ) public override returns (bytes4) { 31 | if (_error == Error.RevertWithMessage) { 32 | revert("ERC721ReceiverMock: reverting"); 33 | } else if (_error == Error.RevertWithoutMessage) { 34 | revert(); 35 | } else if (_error == Error.Panic) { 36 | uint256 a = uint256(0) / uint256(0); 37 | a; 38 | } 39 | emit Received(operator, from, tokenId, data, gasleft()); 40 | return _retval; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721RoyaltyMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/extensions/ERC721Royalty.sol"; 6 | 7 | contract ERC721RoyaltyMock is ERC721Royalty { 8 | constructor(string memory name, string memory symbol) ERC721(name, symbol) {} 9 | 10 | function setTokenRoyalty( 11 | uint256 tokenId, 12 | address recipient, 13 | uint96 fraction 14 | ) public { 15 | _setTokenRoyalty(tokenId, recipient, fraction); 16 | } 17 | 18 | function setDefaultRoyalty(address recipient, uint96 fraction) public { 19 | _setDefaultRoyalty(recipient, fraction); 20 | } 21 | 22 | function mint(address to, uint256 tokenId) public { 23 | _mint(to, tokenId); 24 | } 25 | 26 | function burn(uint256 tokenId) public { 27 | _burn(tokenId); 28 | } 29 | 30 | function deleteDefaultRoyalty() public { 31 | _deleteDefaultRoyalty(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721URIStorageMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/extensions/ERC721URIStorage.sol"; 6 | 7 | /** 8 | * @title ERC721Mock 9 | * This mock just provides a public safeMint, mint, and burn functions for testing purposes 10 | */ 11 | contract ERC721URIStorageMock is ERC721URIStorage { 12 | string private _baseTokenURI; 13 | 14 | constructor(string memory name, string memory symbol) ERC721(name, symbol) {} 15 | 16 | function _baseURI() internal view virtual override returns (string memory) { 17 | return _baseTokenURI; 18 | } 19 | 20 | function setBaseURI(string calldata newBaseTokenURI) public { 21 | _baseTokenURI = newBaseTokenURI; 22 | } 23 | 24 | function baseURI() public view returns (string memory) { 25 | return _baseURI(); 26 | } 27 | 28 | function setTokenURI(uint256 tokenId, string memory _tokenURI) public { 29 | _setTokenURI(tokenId, _tokenURI); 30 | } 31 | 32 | function exists(uint256 tokenId) public view returns (bool) { 33 | return _exists(tokenId); 34 | } 35 | 36 | function mint(address to, uint256 tokenId) public { 37 | _mint(to, tokenId); 38 | } 39 | 40 | function safeMint(address to, uint256 tokenId) public { 41 | _safeMint(to, tokenId); 42 | } 43 | 44 | function safeMint( 45 | address to, 46 | uint256 tokenId, 47 | bytes memory _data 48 | ) public { 49 | _safeMint(to, tokenId, _data); 50 | } 51 | 52 | function burn(uint256 tokenId) public { 53 | _burn(tokenId); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC721VotesMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../token/ERC721/extensions/draft-ERC721Votes.sol"; 6 | 7 | contract ERC721VotesMock is ERC721Votes { 8 | constructor(string memory name, string memory symbol) ERC721(name, symbol) EIP712(name, "1") {} 9 | 10 | function getTotalSupply() public view returns (uint256) { 11 | return _getTotalSupply(); 12 | } 13 | 14 | function mint(address account, uint256 tokenId) public { 15 | _mint(account, tokenId); 16 | } 17 | 18 | function burn(uint256 tokenId) public { 19 | _burn(tokenId); 20 | } 21 | 22 | function getChainId() external view returns (uint256) { 23 | return block.chainid; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ERC777Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Context.sol"; 6 | import "../token/ERC777/ERC777.sol"; 7 | 8 | contract ERC777Mock is Context, ERC777 { 9 | event BeforeTokenTransfer(); 10 | 11 | constructor( 12 | address initialHolder, 13 | uint256 initialBalance, 14 | string memory name, 15 | string memory symbol, 16 | address[] memory defaultOperators 17 | ) ERC777(name, symbol, defaultOperators) { 18 | _mint(initialHolder, initialBalance, "", ""); 19 | } 20 | 21 | function mintInternal( 22 | address to, 23 | uint256 amount, 24 | bytes memory userData, 25 | bytes memory operatorData 26 | ) public { 27 | _mint(to, amount, userData, operatorData); 28 | } 29 | 30 | function mintInternalExtended( 31 | address to, 32 | uint256 amount, 33 | bytes memory userData, 34 | bytes memory operatorData, 35 | bool requireReceptionAck 36 | ) public { 37 | _mint(to, amount, userData, operatorData, requireReceptionAck); 38 | } 39 | 40 | function approveInternal( 41 | address holder, 42 | address spender, 43 | uint256 value 44 | ) public { 45 | _approve(holder, spender, value); 46 | } 47 | 48 | function _beforeTokenTransfer( 49 | address, 50 | address, 51 | address, 52 | uint256 53 | ) internal override { 54 | emit BeforeTokenTransfer(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/EnumerableMapMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/structs/EnumerableMap.sol"; 6 | 7 | contract EnumerableMapMock { 8 | using EnumerableMap for EnumerableMap.UintToAddressMap; 9 | 10 | event OperationResult(bool result); 11 | 12 | EnumerableMap.UintToAddressMap private _map; 13 | 14 | function contains(uint256 key) public view returns (bool) { 15 | return _map.contains(key); 16 | } 17 | 18 | function set(uint256 key, address value) public { 19 | bool result = _map.set(key, value); 20 | emit OperationResult(result); 21 | } 22 | 23 | function remove(uint256 key) public { 24 | bool result = _map.remove(key); 25 | emit OperationResult(result); 26 | } 27 | 28 | function length() public view returns (uint256) { 29 | return _map.length(); 30 | } 31 | 32 | function at(uint256 index) public view returns (uint256 key, address value) { 33 | return _map.at(index); 34 | } 35 | 36 | function tryGet(uint256 key) public view returns (bool, address) { 37 | return _map.tryGet(key); 38 | } 39 | 40 | function get(uint256 key) public view returns (address) { 41 | return _map.get(key); 42 | } 43 | 44 | function getWithMessage(uint256 key, string calldata errorMessage) public view returns (address) { 45 | return _map.get(key, errorMessage); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/EtherReceiverMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | contract EtherReceiverMock { 6 | bool private _acceptEther; 7 | 8 | function setAcceptEther(bool acceptEther) public { 9 | _acceptEther = acceptEther; 10 | } 11 | 12 | receive() external payable { 13 | if (!_acceptEther) { 14 | revert(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/GovernorCompMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../governance/extensions/GovernorCountingSimple.sol"; 6 | import "../governance/extensions/GovernorVotesComp.sol"; 7 | 8 | contract GovernorCompMock is GovernorVotesComp, GovernorCountingSimple { 9 | constructor(string memory name_, ERC20VotesComp token_) Governor(name_) GovernorVotesComp(token_) {} 10 | 11 | function quorum(uint256) public pure override returns (uint256) { 12 | return 0; 13 | } 14 | 15 | function votingDelay() public pure override returns (uint256) { 16 | return 4; 17 | } 18 | 19 | function votingPeriod() public pure override returns (uint256) { 20 | return 16; 21 | } 22 | 23 | function cancel( 24 | address[] memory targets, 25 | uint256[] memory values, 26 | bytes[] memory calldatas, 27 | bytes32 salt 28 | ) public returns (uint256 proposalId) { 29 | return _cancel(targets, values, calldatas, salt); 30 | } 31 | 32 | function getVotes(address account, uint256 blockNumber) 33 | public 34 | view 35 | virtual 36 | override(IGovernor, GovernorVotesComp) 37 | returns (uint256) 38 | { 39 | return super.getVotes(account, blockNumber); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/GovernorVoteMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../governance/extensions/GovernorCountingSimple.sol"; 6 | import "../governance/extensions/GovernorVotes.sol"; 7 | 8 | contract GovernorVoteMocks is GovernorVotes, GovernorCountingSimple { 9 | constructor(string memory name_, IVotes token_) Governor(name_) GovernorVotes(token_) {} 10 | 11 | function quorum(uint256) public pure override returns (uint256) { 12 | return 0; 13 | } 14 | 15 | function votingDelay() public pure override returns (uint256) { 16 | return 4; 17 | } 18 | 19 | function votingPeriod() public pure override returns (uint256) { 20 | return 16; 21 | } 22 | 23 | function cancel( 24 | address[] memory targets, 25 | uint256[] memory values, 26 | bytes[] memory calldatas, 27 | bytes32 salt 28 | ) public returns (uint256 proposalId) { 29 | return _cancel(targets, values, calldatas, salt); 30 | } 31 | 32 | function getVotes(address account, uint256 blockNumber) 33 | public 34 | view 35 | virtual 36 | override(IGovernor, GovernorVotes) 37 | returns (uint256) 38 | { 39 | return super.getVotes(account, blockNumber); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/MathMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/math/Math.sol"; 6 | 7 | contract MathMock { 8 | function max(uint256 a, uint256 b) public pure returns (uint256) { 9 | return Math.max(a, b); 10 | } 11 | 12 | function min(uint256 a, uint256 b) public pure returns (uint256) { 13 | return Math.min(a, b); 14 | } 15 | 16 | function average(uint256 a, uint256 b) public pure returns (uint256) { 17 | return Math.average(a, b); 18 | } 19 | 20 | function ceilDiv(uint256 a, uint256 b) public pure returns (uint256) { 21 | return Math.ceilDiv(a, b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/MerkleProofWrapper.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/cryptography/MerkleProof.sol"; 6 | 7 | contract MerkleProofWrapper { 8 | function verify( 9 | bytes32[] memory proof, 10 | bytes32 root, 11 | bytes32 leaf 12 | ) public pure returns (bool) { 13 | return MerkleProof.verify(proof, root, leaf); 14 | } 15 | 16 | function processProof(bytes32[] memory proof, bytes32 leaf) public pure returns (bytes32) { 17 | return MerkleProof.processProof(proof, leaf); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/MulticallTest.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "./MulticallTokenMock.sol"; 6 | 7 | contract MulticallTest { 8 | function testReturnValues( 9 | MulticallTokenMock multicallToken, 10 | address[] calldata recipients, 11 | uint256[] calldata amounts 12 | ) external { 13 | bytes[] memory calls = new bytes[](recipients.length); 14 | for (uint256 i = 0; i < recipients.length; i++) { 15 | calls[i] = abi.encodeWithSignature("transfer(address,uint256)", recipients[i], amounts[i]); 16 | } 17 | 18 | bytes[] memory results = multicallToken.multicall(calls); 19 | for (uint256 i = 0; i < results.length; i++) { 20 | require(abi.decode(results[i], (bool))); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/MulticallTokenMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Multicall.sol"; 6 | import "./ERC20Mock.sol"; 7 | 8 | contract MulticallTokenMock is ERC20Mock, Multicall { 9 | constructor(uint256 initialBalance) ERC20Mock("MulticallToken", "BCT", msg.sender, initialBalance) {} 10 | } 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/OwnableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../access/Ownable.sol"; 6 | 7 | contract OwnableMock is Ownable {} 8 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/PausableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../security/Pausable.sol"; 6 | 7 | contract PausableMock is Pausable { 8 | bool public drasticMeasureTaken; 9 | uint256 public count; 10 | 11 | constructor() { 12 | drasticMeasureTaken = false; 13 | count = 0; 14 | } 15 | 16 | function normalProcess() external whenNotPaused { 17 | count++; 18 | } 19 | 20 | function drasticMeasure() external whenPaused { 21 | drasticMeasureTaken = true; 22 | } 23 | 24 | function pause() external { 25 | _pause(); 26 | } 27 | 28 | function unpause() external { 29 | _unpause(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/PullPaymentMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../security/PullPayment.sol"; 6 | 7 | // mock class using PullPayment 8 | contract PullPaymentMock is PullPayment { 9 | constructor() payable {} 10 | 11 | // test helper function to call asyncTransfer 12 | function callTransfer(address dest, uint256 amount) public { 13 | _asyncTransfer(dest, amount); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ReentrancyAttack.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Context.sol"; 6 | 7 | contract ReentrancyAttack is Context { 8 | function callSender(bytes4 data) public { 9 | (bool success, ) = _msgSender().call(abi.encodeWithSelector(data)); 10 | require(success, "ReentrancyAttack: failed call"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/ReentrancyMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../security/ReentrancyGuard.sol"; 6 | import "./ReentrancyAttack.sol"; 7 | 8 | contract ReentrancyMock is ReentrancyGuard { 9 | uint256 public counter; 10 | 11 | constructor() { 12 | counter = 0; 13 | } 14 | 15 | function callback() external nonReentrant { 16 | _count(); 17 | } 18 | 19 | function countLocalRecursive(uint256 n) public nonReentrant { 20 | if (n > 0) { 21 | _count(); 22 | countLocalRecursive(n - 1); 23 | } 24 | } 25 | 26 | function countThisRecursive(uint256 n) public nonReentrant { 27 | if (n > 0) { 28 | _count(); 29 | (bool success, ) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); 30 | require(success, "ReentrancyMock: failed call"); 31 | } 32 | } 33 | 34 | function countAndCall(ReentrancyAttack attacker) public nonReentrant { 35 | _count(); 36 | bytes4 func = bytes4(keccak256("callback()")); 37 | attacker.callSender(func); 38 | } 39 | 40 | function _count() private { 41 | counter += 1; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/RegressionImplementation.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../proxy/utils/Initializable.sol"; 6 | 7 | contract Implementation1 is Initializable { 8 | uint256 internal _value; 9 | 10 | function initialize() public initializer {} 11 | 12 | function setValue(uint256 _number) public { 13 | _value = _number; 14 | } 15 | } 16 | 17 | contract Implementation2 is Initializable { 18 | uint256 internal _value; 19 | 20 | function initialize() public initializer {} 21 | 22 | function setValue(uint256 _number) public { 23 | _value = _number; 24 | } 25 | 26 | function getValue() public view returns (uint256) { 27 | return _value; 28 | } 29 | } 30 | 31 | contract Implementation3 is Initializable { 32 | uint256 internal _value; 33 | 34 | function initialize() public initializer {} 35 | 36 | function setValue(uint256 _number) public { 37 | _value = _number; 38 | } 39 | 40 | function getValue(uint256 _number) public view returns (uint256) { 41 | return _value + _number; 42 | } 43 | } 44 | 45 | contract Implementation4 is Initializable { 46 | uint256 internal _value; 47 | 48 | function initialize() public initializer {} 49 | 50 | function setValue(uint256 _number) public { 51 | _value = _number; 52 | } 53 | 54 | function getValue() public view returns (uint256) { 55 | return _value; 56 | } 57 | 58 | fallback() external { 59 | _value = 1; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/SignatureCheckerMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/cryptography/SignatureChecker.sol"; 6 | 7 | contract SignatureCheckerMock { 8 | using SignatureChecker for address; 9 | 10 | function isValidSignatureNow( 11 | address signer, 12 | bytes32 hash, 13 | bytes memory signature 14 | ) public view returns (bool) { 15 | return signer.isValidSignatureNow(hash, signature); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/SignedMathMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/math/SignedMath.sol"; 6 | 7 | contract SignedMathMock { 8 | function max(int256 a, int256 b) public pure returns (int256) { 9 | return SignedMath.max(a, b); 10 | } 11 | 12 | function min(int256 a, int256 b) public pure returns (int256) { 13 | return SignedMath.min(a, b); 14 | } 15 | 16 | function average(int256 a, int256 b) public pure returns (int256) { 17 | return SignedMath.average(a, b); 18 | } 19 | 20 | function abs(int256 n) public pure returns (uint256) { 21 | return SignedMath.abs(n); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/SignedSafeMathMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/math/SignedSafeMath.sol"; 6 | 7 | contract SignedSafeMathMock { 8 | function mul(int256 a, int256 b) public pure returns (int256) { 9 | return SignedSafeMath.mul(a, b); 10 | } 11 | 12 | function div(int256 a, int256 b) public pure returns (int256) { 13 | return SignedSafeMath.div(a, b); 14 | } 15 | 16 | function sub(int256 a, int256 b) public pure returns (int256) { 17 | return SignedSafeMath.sub(a, b); 18 | } 19 | 20 | function add(int256 a, int256 b) public pure returns (int256) { 21 | return SignedSafeMath.add(a, b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/SingleInheritanceInitializableMocks.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../proxy/utils/Initializable.sol"; 6 | 7 | /** 8 | * @title MigratableMockV1 9 | * @dev This contract is a mock to test initializable functionality through migrations 10 | */ 11 | contract MigratableMockV1 is Initializable { 12 | uint256 public x; 13 | 14 | function initialize(uint256 value) public payable initializer { 15 | x = value; 16 | } 17 | } 18 | 19 | /** 20 | * @title MigratableMockV2 21 | * @dev This contract is a mock to test migratable functionality with params 22 | */ 23 | contract MigratableMockV2 is MigratableMockV1 { 24 | bool internal _migratedV2; 25 | uint256 public y; 26 | 27 | function migrate(uint256 value, uint256 anotherValue) public payable { 28 | require(!_migratedV2); 29 | x = value; 30 | y = anotherValue; 31 | _migratedV2 = true; 32 | } 33 | } 34 | 35 | /** 36 | * @title MigratableMockV3 37 | * @dev This contract is a mock to test migratable functionality without params 38 | */ 39 | contract MigratableMockV3 is MigratableMockV2 { 40 | bool internal _migratedV3; 41 | 42 | function migrate() public payable { 43 | require(!_migratedV3); 44 | uint256 oldX = x; 45 | x = y; 46 | y = oldX; 47 | _migratedV3 = true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/StorageSlotMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/StorageSlot.sol"; 6 | 7 | contract StorageSlotMock { 8 | using StorageSlot for bytes32; 9 | 10 | function setBoolean(bytes32 slot, bool value) public { 11 | slot.getBooleanSlot().value = value; 12 | } 13 | 14 | function setAddress(bytes32 slot, address value) public { 15 | slot.getAddressSlot().value = value; 16 | } 17 | 18 | function setBytes32(bytes32 slot, bytes32 value) public { 19 | slot.getBytes32Slot().value = value; 20 | } 21 | 22 | function setUint256(bytes32 slot, uint256 value) public { 23 | slot.getUint256Slot().value = value; 24 | } 25 | 26 | function getBoolean(bytes32 slot) public view returns (bool) { 27 | return slot.getBooleanSlot().value; 28 | } 29 | 30 | function getAddress(bytes32 slot) public view returns (address) { 31 | return slot.getAddressSlot().value; 32 | } 33 | 34 | function getBytes32(bytes32 slot) public view returns (bytes32) { 35 | return slot.getBytes32Slot().value; 36 | } 37 | 38 | function getUint256(bytes32 slot) public view returns (uint256) { 39 | return slot.getUint256Slot().value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/StringsMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Strings.sol"; 6 | 7 | contract StringsMock { 8 | function fromUint256(uint256 value) public pure returns (string memory) { 9 | return Strings.toString(value); 10 | } 11 | 12 | function fromUint256Hex(uint256 value) public pure returns (string memory) { 13 | return Strings.toHexString(value); 14 | } 15 | 16 | function fromUint256HexFixed(uint256 value, uint256 length) public pure returns (string memory) { 17 | return Strings.toHexString(value, length); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/TimersBlockNumberImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Timers.sol"; 6 | 7 | contract TimersBlockNumberImpl { 8 | using Timers for Timers.BlockNumber; 9 | 10 | Timers.BlockNumber private _timer; 11 | 12 | function getDeadline() public view returns (uint64) { 13 | return _timer.getDeadline(); 14 | } 15 | 16 | function setDeadline(uint64 timestamp) public { 17 | _timer.setDeadline(timestamp); 18 | } 19 | 20 | function reset() public { 21 | _timer.reset(); 22 | } 23 | 24 | function isUnset() public view returns (bool) { 25 | return _timer.isUnset(); 26 | } 27 | 28 | function isStarted() public view returns (bool) { 29 | return _timer.isStarted(); 30 | } 31 | 32 | function isPending() public view returns (bool) { 33 | return _timer.isPending(); 34 | } 35 | 36 | function isExpired() public view returns (bool) { 37 | return _timer.isExpired(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/TimersTimestampImpl.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../utils/Timers.sol"; 6 | 7 | contract TimersTimestampImpl { 8 | using Timers for Timers.Timestamp; 9 | 10 | Timers.Timestamp private _timer; 11 | 12 | function getDeadline() public view returns (uint64) { 13 | return _timer.getDeadline(); 14 | } 15 | 16 | function setDeadline(uint64 timestamp) public { 17 | _timer.setDeadline(timestamp); 18 | } 19 | 20 | function reset() public { 21 | _timer.reset(); 22 | } 23 | 24 | function isUnset() public view returns (bool) { 25 | return _timer.isUnset(); 26 | } 27 | 28 | function isStarted() public view returns (bool) { 29 | return _timer.isStarted(); 30 | } 31 | 32 | function isPending() public view returns (bool) { 33 | return _timer.isPending(); 34 | } 35 | 36 | function isExpired() public view returns (bool) { 37 | return _timer.isExpired(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/UUPS/UUPSUpgradeableMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../CountersImpl.sol"; 6 | import "../../proxy/utils/UUPSUpgradeable.sol"; 7 | 8 | contract UUPSUpgradeableMock is CountersImpl, UUPSUpgradeable { 9 | // Not having any checks in this function is dangerous! Do not do this outside tests! 10 | function _authorizeUpgrade(address) internal virtual override {} 11 | } 12 | 13 | contract UUPSUpgradeableUnsafeMock is UUPSUpgradeableMock { 14 | function upgradeTo(address newImplementation) external virtual override { 15 | ERC1967Upgrade._upgradeToAndCall(newImplementation, bytes(""), false); 16 | } 17 | 18 | function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual override { 19 | ERC1967Upgrade._upgradeToAndCall(newImplementation, data, false); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/mocks/VotesMock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.0; 4 | 5 | import "../governance/utils/Votes.sol"; 6 | 7 | contract VotesMock is Votes { 8 | mapping(address => uint256) private _balances; 9 | mapping(uint256 => address) private _owners; 10 | 11 | constructor(string memory name) EIP712(name, "1") {} 12 | 13 | function getTotalSupply() public view returns (uint256) { 14 | return _getTotalSupply(); 15 | } 16 | 17 | function delegate(address account, address newDelegation) public { 18 | return _delegate(account, newDelegation); 19 | } 20 | 21 | function _getVotingUnits(address account) internal virtual override returns (uint256) { 22 | return _balances[account]; 23 | } 24 | 25 | function mint(address account, uint256 voteId) external { 26 | _balances[account] += 1; 27 | _owners[voteId] = account; 28 | _transferVotingUnits(address(0), account, 1); 29 | } 30 | 31 | function burn(uint256 voteId) external { 32 | address owner = _owners[voteId]; 33 | _balances[owner] -= 1; 34 | _transferVotingUnits(owner, address(0), 1); 35 | } 36 | 37 | function getChainId() external view returns (uint256) { 38 | return block.chainid; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@openzeppelin/contracts", 3 | "description": "Secure Smart Contract library for Solidity", 4 | "version": "4.5.0", 5 | "files": [ 6 | "**/*.sol", 7 | "/build/contracts/*.json", 8 | "!/mocks/**/*" 9 | ], 10 | "scripts": { 11 | "prepare": "bash ../scripts/prepare-contracts-package.sh", 12 | "prepare-docs": "cd ..; npm run prepare-docs" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts.git" 17 | }, 18 | "keywords": [ 19 | "solidity", 20 | "ethereum", 21 | "smart", 22 | "contracts", 23 | "security", 24 | "zeppelin" 25 | ], 26 | "author": "OpenZeppelin Community ", 27 | "license": "MIT", 28 | "bugs": { 29 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" 30 | }, 31 | "homepage": "https://openzeppelin.com/contracts/" 32 | } 33 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../Proxy.sol"; 7 | import "./ERC1967Upgrade.sol"; 8 | 9 | /** 10 | * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an 11 | * implementation address that can be changed. This address is stored in storage in the location specified by 12 | * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the 13 | * implementation behind the proxy. 14 | */ 15 | contract ERC1967Proxy is Proxy, ERC1967Upgrade { 16 | /** 17 | * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. 18 | * 19 | * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded 20 | * function call, and allows initializating the storage of the proxy like a Solidity constructor. 21 | */ 22 | constructor(address _logic, bytes memory _data) payable { 23 | assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); 24 | _upgradeToAndCall(_logic, _data, false); 25 | } 26 | 27 | /** 28 | * @dev Returns the current implementation address. 29 | */ 30 | function _implementation() internal view virtual override returns (address impl) { 31 | return ERC1967Upgrade._getImplementation(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev This is the interface that {BeaconProxy} expects of its beacon. 8 | */ 9 | interface IBeacon { 10 | /** 11 | * @dev Must return an address that can be used as a delegate call target. 12 | * 13 | * {BeaconProxy} will check that this address is a contract. 14 | */ 15 | function implementation() external view returns (address); 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/security/README.adoc: -------------------------------------------------------------------------------- 1 | = Security 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/security 5 | 6 | These contracts aim to cover common security practices. 7 | 8 | * {PullPayment}: A pattern that can be used to avoid reentrancy attacks. 9 | * {ReentrancyGuard}: A modifier that can prevent reentrancy during certain functions. 10 | * {Pausable}: A common emergency response mechanism that can pause functionality while a remediation is pending. 11 | 12 | TIP: For an overview on reentrancy and the possible mechanisms to prevent it, read our article https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. 13 | 14 | == Contracts 15 | 16 | {{PullPayment}} 17 | 18 | {{ReentrancyGuard}} 19 | 20 | {{Pausable}} 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/ERC1155Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Burnable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC1155.sol"; 7 | 8 | /** 9 | * @dev Extension of {ERC1155} that allows token holders to destroy both their 10 | * own tokens and those that they have been approved to use. 11 | * 12 | * _Available since v3.1._ 13 | */ 14 | abstract contract ERC1155Burnable is ERC1155 { 15 | function burn( 16 | address account, 17 | uint256 id, 18 | uint256 value 19 | ) public virtual { 20 | require( 21 | account == _msgSender() || isApprovedForAll(account, _msgSender()), 22 | "ERC1155: caller is not owner nor approved" 23 | ); 24 | 25 | _burn(account, id, value); 26 | } 27 | 28 | function burnBatch( 29 | address account, 30 | uint256[] memory ids, 31 | uint256[] memory values 32 | ) public virtual { 33 | require( 34 | account == _msgSender() || isApprovedForAll(account, _msgSender()), 35 | "ERC1155: caller is not owner nor approved" 36 | ); 37 | 38 | _burnBatch(account, ids, values); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/ERC1155Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Pausable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC1155.sol"; 7 | import "../../../security/Pausable.sol"; 8 | 9 | /** 10 | * @dev ERC1155 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | * 16 | * _Available since v3.1._ 17 | */ 18 | abstract contract ERC1155Pausable is ERC1155, Pausable { 19 | /** 20 | * @dev See {ERC1155-_beforeTokenTransfer}. 21 | * 22 | * Requirements: 23 | * 24 | * - the contract must not be paused. 25 | */ 26 | function _beforeTokenTransfer( 27 | address operator, 28 | address from, 29 | address to, 30 | uint256[] memory ids, 31 | uint256[] memory amounts, 32 | bytes memory data 33 | ) internal virtual override { 34 | super._beforeTokenTransfer(operator, from, to, ids, amounts, data); 35 | 36 | require(!paused(), "ERC1155Pausable: token transfer while paused"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC1155.sol"; 7 | 8 | /** 9 | * @dev Interface of the optional ERC1155MetadataExtension interface, as defined 10 | * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. 11 | * 12 | * _Available since v3.1._ 13 | */ 14 | interface IERC1155MetadataURI is IERC1155 { 15 | /** 16 | * @dev Returns the URI for token type `id`. 17 | * 18 | * If the `\{id\}` substring is present in the URI, it must be replaced by 19 | * clients with the actual token type ID. 20 | */ 21 | function uri(uint256 id) external view returns (string memory); 22 | } 23 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/presets/README.md: -------------------------------------------------------------------------------- 1 | Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative. 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/utils/ERC1155Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./ERC1155Receiver.sol"; 7 | 8 | /** 9 | * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. 10 | * 11 | * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be 12 | * stuck. 13 | * 14 | * @dev _Available since v3.1._ 15 | */ 16 | contract ERC1155Holder is ERC1155Receiver { 17 | function onERC1155Received( 18 | address, 19 | address, 20 | uint256, 21 | uint256, 22 | bytes memory 23 | ) public virtual override returns (bytes4) { 24 | return this.onERC1155Received.selector; 25 | } 26 | 27 | function onERC1155BatchReceived( 28 | address, 29 | address, 30 | uint256[] memory, 31 | uint256[] memory, 32 | bytes memory 33 | ) public virtual override returns (bytes4) { 34 | return this.onERC1155BatchReceived.selector; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC1155/utils/ERC1155Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC1155Receiver.sol"; 7 | import "../../../utils/introspection/ERC165.sol"; 8 | 9 | /** 10 | * @dev _Available since v3.1._ 11 | */ 12 | abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { 13 | /** 14 | * @dev See {IERC165-supportsInterface}. 15 | */ 16 | function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { 17 | return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC20.sol"; 7 | import "../../../utils/Context.sol"; 8 | 9 | /** 10 | * @dev Extension of {ERC20} that allows token holders to destroy both their own 11 | * tokens and those that they have an allowance for, in a way that can be 12 | * recognized off-chain (via event analysis). 13 | */ 14 | abstract contract ERC20Burnable is Context, ERC20 { 15 | /** 16 | * @dev Destroys `amount` tokens from the caller. 17 | * 18 | * See {ERC20-_burn}. 19 | */ 20 | function burn(uint256 amount) public virtual { 21 | _burn(_msgSender(), amount); 22 | } 23 | 24 | /** 25 | * @dev Destroys `amount` tokens from `account`, deducting from the caller's 26 | * allowance. 27 | * 28 | * See {ERC20-_burn} and {ERC20-allowance}. 29 | * 30 | * Requirements: 31 | * 32 | * - the caller must have allowance for ``accounts``'s tokens of at least 33 | * `amount`. 34 | */ 35 | function burnFrom(address account, uint256 amount) public virtual { 36 | _spendAllowance(account, _msgSender(), amount); 37 | _burn(account, amount); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Capped.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC20.sol"; 7 | 8 | /** 9 | * @dev Extension of {ERC20} that adds a cap to the supply of tokens. 10 | */ 11 | abstract contract ERC20Capped is ERC20 { 12 | uint256 private immutable _cap; 13 | 14 | /** 15 | * @dev Sets the value of the `cap`. This value is immutable, it can only be 16 | * set once during construction. 17 | */ 18 | constructor(uint256 cap_) { 19 | require(cap_ > 0, "ERC20Capped: cap is 0"); 20 | _cap = cap_; 21 | } 22 | 23 | /** 24 | * @dev Returns the cap on the token's total supply. 25 | */ 26 | function cap() public view virtual returns (uint256) { 27 | return _cap; 28 | } 29 | 30 | /** 31 | * @dev See {ERC20-_mint}. 32 | */ 33 | function _mint(address account, uint256 amount) internal virtual override { 34 | require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded"); 35 | super._mint(account, amount); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC20.sol"; 7 | import "../../../security/Pausable.sol"; 8 | 9 | /** 10 | * @dev ERC20 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | */ 16 | abstract contract ERC20Pausable is ERC20, Pausable { 17 | /** 18 | * @dev See {ERC20-_beforeTokenTransfer}. 19 | * 20 | * Requirements: 21 | * 22 | * - the contract must not be paused. 23 | */ 24 | function _beforeTokenTransfer( 25 | address from, 26 | address to, 27 | uint256 amount 28 | ) internal virtual override { 29 | super._beforeTokenTransfer(from, to, amount); 30 | 31 | require(!paused(), "ERC20Pausable: token transfer while paused"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC20.sol"; 7 | 8 | /** 9 | * @dev Interface for the optional metadata functions from the ERC20 standard. 10 | * 11 | * _Available since v4.1._ 12 | */ 13 | interface IERC20Metadata is IERC20 { 14 | /** 15 | * @dev Returns the name of the token. 16 | */ 17 | function name() external view returns (string memory); 18 | 19 | /** 20 | * @dev Returns the symbol of the token. 21 | */ 22 | function symbol() external view returns (string memory); 23 | 24 | /** 25 | * @dev Returns the decimals places of the token. 26 | */ 27 | function decimals() external view returns (uint8); 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/presets/ERC20PresetFixedSupply.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | import "../extensions/ERC20Burnable.sol"; 6 | 7 | /** 8 | * @dev {ERC20} token, including: 9 | * 10 | * - Preminted initial supply 11 | * - Ability for holders to burn (destroy) their tokens 12 | * - No access control mechanism (for minting/pausing) and hence no governance 13 | * 14 | * This contract uses {ERC20Burnable} to include burn capabilities - head to 15 | * its documentation for details. 16 | * 17 | * _Available since v3.4._ 18 | * 19 | * _Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard]._ 20 | */ 21 | contract ERC20PresetFixedSupply is ERC20Burnable { 22 | /** 23 | * @dev Mints `initialSupply` amount of token and transfers them to `owner`. 24 | * 25 | * See {ERC20-constructor}. 26 | */ 27 | constructor( 28 | string memory name, 29 | string memory symbol, 30 | uint256 initialSupply, 31 | address owner 32 | ) ERC20(name, symbol) { 33 | _mint(owner, initialSupply); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC20/presets/README.md: -------------------------------------------------------------------------------- 1 | Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative. 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/IERC721Receiver.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @title ERC721 token receiver interface 8 | * @dev Interface for any contract that wants to support safeTransfers 9 | * from ERC721 asset contracts. 10 | */ 11 | interface IERC721Receiver { 12 | /** 13 | * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} 14 | * by `operator` from `from`, this function is called. 15 | * 16 | * It must return its Solidity selector to confirm the token transfer. 17 | * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. 18 | * 19 | * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. 20 | */ 21 | function onERC721Received( 22 | address operator, 23 | address from, 24 | uint256 tokenId, 25 | bytes calldata data 26 | ) external returns (bytes4); 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Burnable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Burnable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC721.sol"; 7 | import "../../../utils/Context.sol"; 8 | 9 | /** 10 | * @title ERC721 Burnable Token 11 | * @dev ERC721 Token that can be irreversibly burned (destroyed). 12 | */ 13 | abstract contract ERC721Burnable is Context, ERC721 { 14 | /** 15 | * @dev Burns `tokenId`. See {ERC721-_burn}. 16 | * 17 | * Requirements: 18 | * 19 | * - The caller must own `tokenId` or be an approved operator. 20 | */ 21 | function burn(uint256 tokenId) public virtual { 22 | //solhint-disable-next-line max-line-length 23 | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); 24 | _burn(tokenId); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/ERC721Pausable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Pausable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC721.sol"; 7 | import "../../../security/Pausable.sol"; 8 | 9 | /** 10 | * @dev ERC721 token with pausable token transfers, minting and burning. 11 | * 12 | * Useful for scenarios such as preventing trades until the end of an evaluation 13 | * period, or having an emergency switch for freezing all token transfers in the 14 | * event of a large bug. 15 | */ 16 | abstract contract ERC721Pausable is ERC721, Pausable { 17 | /** 18 | * @dev See {ERC721-_beforeTokenTransfer}. 19 | * 20 | * Requirements: 21 | * 22 | * - the contract must not be paused. 23 | */ 24 | function _beforeTokenTransfer( 25 | address from, 26 | address to, 27 | uint256 tokenId 28 | ) internal virtual override { 29 | super._beforeTokenTransfer(from, to, tokenId); 30 | 31 | require(!paused(), "ERC721Pausable: token transfer while paused"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Enumerable.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721.sol"; 7 | 8 | /** 9 | * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension 10 | * @dev See https://eips.ethereum.org/EIPS/eip-721 11 | */ 12 | interface IERC721Enumerable is IERC721 { 13 | /** 14 | * @dev Returns the total amount of tokens stored by the contract. 15 | */ 16 | function totalSupply() external view returns (uint256); 17 | 18 | /** 19 | * @dev Returns a token ID owned by `owner` at a given `index` of its token list. 20 | * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. 21 | */ 22 | function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); 23 | 24 | /** 25 | * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. 26 | * Use along with {totalSupply} to enumerate all tokens. 27 | */ 28 | function tokenByIndex(uint256 index) external view returns (uint256); 29 | } 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/IERC721Metadata.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721.sol"; 7 | 8 | /** 9 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension 10 | * @dev See https://eips.ethereum.org/EIPS/eip-721 11 | */ 12 | interface IERC721Metadata is IERC721 { 13 | /** 14 | * @dev Returns the token collection name. 15 | */ 16 | function name() external view returns (string memory); 17 | 18 | /** 19 | * @dev Returns the token collection symbol. 20 | */ 21 | function symbol() external view returns (string memory); 22 | 23 | /** 24 | * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. 25 | */ 26 | function tokenURI(uint256 tokenId) external view returns (string memory); 27 | } 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/extensions/draft-ERC721Votes.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/draft-ERC721Votes.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../ERC721.sol"; 7 | import "../../../governance/utils/Votes.sol"; 8 | 9 | /** 10 | * @dev Extension of ERC721 to support voting and delegation as implemented by {Votes}, where each individual NFT counts 11 | * as 1 vote unit. 12 | * 13 | * Tokens do not count as votes until they are delegated, because votes must be tracked which incurs an additional cost 14 | * on every transfer. Token holders can either delegate to a trusted representative who will decide how to make use of 15 | * the votes in governance decisions, or they can delegate to themselves to be their own representative. 16 | * 17 | * _Available since v4.5._ 18 | */ 19 | abstract contract ERC721Votes is ERC721, Votes { 20 | /** 21 | * @dev Adjusts votes when tokens are transferred. 22 | * 23 | * Emits a {Votes-DelegateVotesChanged} event. 24 | */ 25 | function _afterTokenTransfer( 26 | address from, 27 | address to, 28 | uint256 tokenId 29 | ) internal virtual override { 30 | _transferVotingUnits(from, to, 1); 31 | super._afterTokenTransfer(from, to, tokenId); 32 | } 33 | 34 | /** 35 | * @dev Returns the balance of `account`. 36 | */ 37 | function _getVotingUnits(address account) internal virtual override returns (uint256) { 38 | return balanceOf(account); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/presets/README.md: -------------------------------------------------------------------------------- 1 | Contract presets are now deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/) as a more powerful alternative. 2 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC721/utils/ERC721Holder.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "../IERC721Receiver.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC721Receiver} interface. 10 | * 11 | * Accepts all token transfers. 12 | * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. 13 | */ 14 | contract ERC721Holder is IERC721Receiver { 15 | /** 16 | * @dev See {IERC721Receiver-onERC721Received}. 17 | * 18 | * Always returns `IERC721Receiver.onERC721Received.selector`. 19 | */ 20 | function onERC721Received( 21 | address, 22 | address, 23 | uint256, 24 | bytes memory 25 | ) public virtual override returns (bytes4) { 26 | return this.onERC721Received.selector; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC777/IERC777Recipient.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Recipient.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. 8 | * 9 | * Accounts can be notified of {IERC777} tokens being sent to them by having a 10 | * contract implement this interface (contract holders can be their own 11 | * implementer) and registering it on the 12 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. 13 | * 14 | * See {IERC1820Registry} and {ERC1820Implementer}. 15 | */ 16 | interface IERC777Recipient { 17 | /** 18 | * @dev Called by an {IERC777} token contract whenever tokens are being 19 | * moved or created into a registered account (`to`). The type of operation 20 | * is conveyed by `from` being the zero address or not. 21 | * 22 | * This call occurs _after_ the token contract's state is updated, so 23 | * {IERC777-balanceOf}, etc., can be used to query the post-operation state. 24 | * 25 | * This function may revert to prevent the operation from being executed. 26 | */ 27 | function tokensReceived( 28 | address operator, 29 | address from, 30 | address to, 31 | uint256 amount, 32 | bytes calldata userData, 33 | bytes calldata operatorData 34 | ) external; 35 | } 36 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC777/IERC777Sender.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Sender.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC777TokensSender standard as defined in the EIP. 8 | * 9 | * {IERC777} Token holders can be notified of operations performed on their 10 | * tokens by having a contract implement this interface (contract holders can be 11 | * their own implementer) and registering it on the 12 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. 13 | * 14 | * See {IERC1820Registry} and {ERC1820Implementer}. 15 | */ 16 | interface IERC777Sender { 17 | /** 18 | * @dev Called by an {IERC777} token contract whenever a registered holder's 19 | * (`from`) tokens are about to be moved or destroyed. The type of operation 20 | * is conveyed by `to` being the zero address or not. 21 | * 22 | * This call occurs _before_ the token contract's state is updated, so 23 | * {IERC777-balanceOf}, etc., can be used to query the pre-operation state. 24 | * 25 | * This function may revert to prevent the operation from being executed. 26 | */ 27 | function tokensToSend( 28 | address operator, 29 | address from, 30 | address to, 31 | uint256 amount, 32 | bytes calldata userData, 33 | bytes calldata operatorData 34 | ) external; 35 | } 36 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC777/README.adoc: -------------------------------------------------------------------------------- 1 | = ERC 777 2 | 3 | [.readme-notice] 4 | NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/token/erc777 5 | 6 | This set of interfaces and contracts are all related to the [ERC777 token standard](https://eips.ethereum.org/EIPS/eip-777). 7 | 8 | TIP: For an overview of ERC777 tokens and a walk through on how to create a token contract read our xref:ROOT:erc777.adoc[ERC777 guide]. 9 | 10 | The token behavior itself is implemented in the core contracts: {IERC777}, {ERC777}. 11 | 12 | Additionally there are interfaces used to develop contracts that react to token movements: {IERC777Sender}, {IERC777Recipient}. 13 | 14 | == Core 15 | 16 | {{IERC777}} 17 | 18 | {{ERC777}} 19 | 20 | == Hooks 21 | 22 | {{IERC777Sender}} 23 | 24 | {{IERC777Recipient}} 25 | 26 | == Presets 27 | 28 | These contracts are preconfigured combinations of features. They can be used through inheritance or as models to copy and paste their source code. 29 | 30 | {{ERC777PresetFixedSupply}} 31 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/ERC777/presets/ERC777PresetFixedSupply.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (token/ERC777/presets/ERC777PresetFixedSupply.sol) 3 | pragma solidity ^0.8.0; 4 | 5 | import "../ERC777.sol"; 6 | 7 | /** 8 | * @dev {ERC777} token, including: 9 | * 10 | * - Preminted initial supply 11 | * - No access control mechanism (for minting/pausing) and hence no governance 12 | * 13 | * _Available since v3.4._ 14 | */ 15 | contract ERC777PresetFixedSupply is ERC777 { 16 | /** 17 | * @dev Mints `initialSupply` amount of token and transfers them to `owner`. 18 | * 19 | * See {ERC777-constructor}. 20 | */ 21 | constructor( 22 | string memory name, 23 | string memory symbol, 24 | address[] memory defaultOperators, 25 | uint256 initialSupply, 26 | address owner 27 | ) ERC777(name, symbol, defaultOperators) { 28 | _mint(owner, initialSupply, "", ""); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/token/common/README.adoc: -------------------------------------------------------------------------------- 1 | = Common (Tokens) 2 | 3 | Functionality that is common to multiple token standards. 4 | 5 | * {ERC2981}: NFT Royalties compatible with both ERC721 and ERC1155. 6 | ** For ERC721 consider {ERC721Royalty} which clears the royalty information from storage on burn. 7 | 8 | == Contracts 9 | 10 | {{ERC2981}} 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/Context.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Provides information about the current execution context, including the 8 | * sender of the transaction and its data. While these are generally available 9 | * via msg.sender and msg.data, they should not be accessed in such a direct 10 | * manner, since when dealing with meta-transactions the account sending and 11 | * paying for execution may not be the actual sender (as far as an application 12 | * is concerned). 13 | * 14 | * This contract is only required for intermediate, library-like contracts. 15 | */ 16 | abstract contract Context { 17 | function _msgSender() internal view virtual returns (address) { 18 | return msg.sender; 19 | } 20 | 21 | function _msgData() internal view virtual returns (bytes calldata) { 22 | return msg.data; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/Counters.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @title Counters 8 | * @author Matt Condon (@shrugs) 9 | * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number 10 | * of elements in a mapping, issuing ERC721 ids, or counting request ids. 11 | * 12 | * Include with `using Counters for Counters.Counter;` 13 | */ 14 | library Counters { 15 | struct Counter { 16 | // This variable should never be directly accessed by users of the library: interactions must be restricted to 17 | // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add 18 | // this feature: see https://github.com/ethereum/solidity/issues/4637 19 | uint256 _value; // default: 0 20 | } 21 | 22 | function current(Counter storage counter) internal view returns (uint256) { 23 | return counter._value; 24 | } 25 | 26 | function increment(Counter storage counter) internal { 27 | unchecked { 28 | counter._value += 1; 29 | } 30 | } 31 | 32 | function decrement(Counter storage counter) internal { 33 | uint256 value = counter._value; 34 | require(value > 0, "Counter: decrement overflow"); 35 | unchecked { 36 | counter._value = value - 1; 37 | } 38 | } 39 | 40 | function reset(Counter storage counter) internal { 41 | counter._value = 0; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/Multicall.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./Address.sol"; 7 | 8 | /** 9 | * @dev Provides a function to batch together multiple calls in a single external call. 10 | * 11 | * _Available since v4.1._ 12 | */ 13 | abstract contract Multicall { 14 | /** 15 | * @dev Receives and executes a batch of function calls on this contract. 16 | */ 17 | function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { 18 | results = new bytes[](data.length); 19 | for (uint256 i = 0; i < data.length; i++) { 20 | results[i] = Address.functionDelegateCall(address(this), data[i]); 21 | } 22 | return results; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/escrow/ConditionalEscrow.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/escrow/ConditionalEscrow.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./Escrow.sol"; 7 | 8 | /** 9 | * @title ConditionalEscrow 10 | * @dev Base abstract escrow to only allow withdrawal if a condition is met. 11 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. 12 | */ 13 | abstract contract ConditionalEscrow is Escrow { 14 | /** 15 | * @dev Returns whether an address is allowed to withdraw their funds. To be 16 | * implemented by derived contracts. 17 | * @param payee The destination address of the funds. 18 | */ 19 | function withdrawalAllowed(address payee) public view virtual returns (bool); 20 | 21 | function withdraw(address payable payee) public virtual override { 22 | require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); 23 | super.withdraw(payee); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC165.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC165} interface. 10 | * 11 | * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check 12 | * for the additional interface id that will be supported. For example: 13 | * 14 | * ```solidity 15 | * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { 16 | * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); 17 | * } 18 | * ``` 19 | * 20 | * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. 21 | */ 22 | abstract contract ERC165 is IERC165 { 23 | /** 24 | * @dev See {IERC165-supportsInterface}. 25 | */ 26 | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { 27 | return interfaceId == type(IERC165).interfaceId; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/ERC165Storage.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./ERC165.sol"; 7 | 8 | /** 9 | * @dev Storage based implementation of the {IERC165} interface. 10 | * 11 | * Contracts may inherit from this and call {_registerInterface} to declare 12 | * their support of an interface. 13 | */ 14 | abstract contract ERC165Storage is ERC165 { 15 | /** 16 | * @dev Mapping of interface ids to whether or not it's supported. 17 | */ 18 | mapping(bytes4 => bool) private _supportedInterfaces; 19 | 20 | /** 21 | * @dev See {IERC165-supportsInterface}. 22 | */ 23 | function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { 24 | return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId]; 25 | } 26 | 27 | /** 28 | * @dev Registers the contract as an implementer of the interface defined by 29 | * `interfaceId`. Support of the actual ERC165 interface is automatic and 30 | * registering its interface id is not required. 31 | * 32 | * See {IERC165-supportsInterface}. 33 | * 34 | * Requirements: 35 | * 36 | * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). 37 | */ 38 | function _registerInterface(bytes4 interfaceId) internal virtual { 39 | require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); 40 | _supportedInterfaces[interfaceId] = true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/ERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | import "./IERC1820Implementer.sol"; 7 | 8 | /** 9 | * @dev Implementation of the {IERC1820Implementer} interface. 10 | * 11 | * Contracts may inherit from this and call {_registerInterfaceForAddress} to 12 | * declare their willingness to be implementers. 13 | * {IERC1820Registry-setInterfaceImplementer} should then be called for the 14 | * registration to be complete. 15 | */ 16 | contract ERC1820Implementer is IERC1820Implementer { 17 | bytes32 private constant _ERC1820_ACCEPT_MAGIC = keccak256("ERC1820_ACCEPT_MAGIC"); 18 | 19 | mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; 20 | 21 | /** 22 | * @dev See {IERC1820Implementer-canImplementInterfaceForAddress}. 23 | */ 24 | function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) 25 | public 26 | view 27 | virtual 28 | override 29 | returns (bytes32) 30 | { 31 | return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00); 32 | } 33 | 34 | /** 35 | * @dev Declares the contract as willing to be an implementer of 36 | * `interfaceHash` for `account`. 37 | * 38 | * See {IERC1820Registry-setInterfaceImplementer} and 39 | * {IERC1820Registry-interfaceHash}. 40 | */ 41 | function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal virtual { 42 | _supportedInterfaces[interfaceHash][account] = true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface of the ERC165 standard, as defined in the 8 | * https://eips.ethereum.org/EIPS/eip-165[EIP]. 9 | * 10 | * Implementers can declare support of contract interfaces, which can then be 11 | * queried by others ({ERC165Checker}). 12 | * 13 | * For an implementation, see {ERC165}. 14 | */ 15 | interface IERC165 { 16 | /** 17 | * @dev Returns true if this contract implements the interface defined by 18 | * `interfaceId`. See the corresponding 19 | * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] 20 | * to learn more about how these ids are created. 21 | * 22 | * This function call must use less than 30 000 gas. 23 | */ 24 | function supportsInterface(bytes4 interfaceId) external view returns (bool); 25 | } 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/introspection/IERC1820Implementer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC1820Implementer.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Interface for an ERC1820 implementer, as defined in the 8 | * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP]. 9 | * Used by contracts that will be registered as implementers in the 10 | * {IERC1820Registry}. 11 | */ 12 | interface IERC1820Implementer { 13 | /** 14 | * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract 15 | * implements `interfaceHash` for `account`. 16 | * 17 | * See {IERC1820Registry-setInterfaceImplementer}. 18 | */ 19 | function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32); 20 | } 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/math/Math.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Standard math utilities missing in the Solidity language. 8 | */ 9 | library Math { 10 | /** 11 | * @dev Returns the largest of two numbers. 12 | */ 13 | function max(uint256 a, uint256 b) internal pure returns (uint256) { 14 | return a >= b ? a : b; 15 | } 16 | 17 | /** 18 | * @dev Returns the smallest of two numbers. 19 | */ 20 | function min(uint256 a, uint256 b) internal pure returns (uint256) { 21 | return a < b ? a : b; 22 | } 23 | 24 | /** 25 | * @dev Returns the average of two numbers. The result is rounded towards 26 | * zero. 27 | */ 28 | function average(uint256 a, uint256 b) internal pure returns (uint256) { 29 | // (a + b) / 2 can overflow. 30 | return (a & b) + (a ^ b) / 2; 31 | } 32 | 33 | /** 34 | * @dev Returns the ceiling of the division of two numbers. 35 | * 36 | * This differs from standard division with `/` in that it rounds up instead 37 | * of rounding down. 38 | */ 39 | function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { 40 | // (a + b - 1) / b can overflow on addition, so we distribute. 41 | return a / b + (a % b == 0 ? 0 : 1); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol) 3 | 4 | pragma solidity ^0.8.0; 5 | 6 | /** 7 | * @dev Standard signed math utilities missing in the Solidity language. 8 | */ 9 | library SignedMath { 10 | /** 11 | * @dev Returns the largest of two signed numbers. 12 | */ 13 | function max(int256 a, int256 b) internal pure returns (int256) { 14 | return a >= b ? a : b; 15 | } 16 | 17 | /** 18 | * @dev Returns the smallest of two signed numbers. 19 | */ 20 | function min(int256 a, int256 b) internal pure returns (int256) { 21 | return a < b ? a : b; 22 | } 23 | 24 | /** 25 | * @dev Returns the average of two signed numbers without overflow. 26 | * The result is rounded towards zero. 27 | */ 28 | function average(int256 a, int256 b) internal pure returns (int256) { 29 | // Formula from the book "Hacker's Delight" 30 | int256 x = (a & b) + ((a ^ b) >> 1); 31 | return x + (int256(uint256(x) >> 255) & (a ^ b)); 32 | } 33 | 34 | /** 35 | * @dev Returns the absolute unsigned value of a signed value. 36 | */ 37 | function abs(int256 n) internal pure returns (uint256) { 38 | unchecked { 39 | // must be unchecked in order to support `n = type(int256).min` 40 | return uint256(n >= 0 ? n : -n); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/antora.yml: -------------------------------------------------------------------------------- 1 | name: contracts 2 | title: Contracts 3 | version: 4.x 4 | nav: 5 | - modules/ROOT/nav.adoc 6 | - modules/api/nav.adoc 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/helpers.js: -------------------------------------------------------------------------------- 1 | const { version } = require('../package.json'); 2 | 3 | module.exports = { 4 | 'github-link': (contractPath) => { 5 | if (typeof contractPath !== 'string') { 6 | throw new Error('Missing argument'); 7 | } 8 | return `https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v${version}/contracts/${contractPath}`; 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DominicChainsecurity/DevconVI/30da17f0f2cfa0169d87c73c7270ab70ea21855d/lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-admin.png -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-vote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DominicChainsecurity/DevconVI/30da17f0f2cfa0169d87c73c7270ab70ea21855d/lib/openzeppelin-contracts/docs/modules/ROOT/images/tally-vote.png -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/modules/ROOT/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:index.adoc[Overview] 2 | * xref:wizard.adoc[Wizard] 3 | * xref:extending-contracts.adoc[Extending Contracts] 4 | * xref:upgradeable.adoc[Using with Upgrades] 5 | 6 | * xref:releases-stability.adoc[Releases & Stability] 7 | 8 | * xref:access-control.adoc[Access Control] 9 | 10 | * xref:tokens.adoc[Tokens] 11 | ** xref:erc20.adoc[ERC20] 12 | *** xref:erc20-supply.adoc[Creating Supply] 13 | ** xref:erc721.adoc[ERC721] 14 | ** xref:erc777.adoc[ERC777] 15 | ** xref:erc1155.adoc[ERC1155] 16 | 17 | * xref:governance.adoc[Governance] 18 | 19 | * xref:utilities.adoc[Utilities] 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/modules/ROOT/pages/crowdsales.adoc: -------------------------------------------------------------------------------- 1 | = Crowdsales 2 | 3 | All crowdsale-related contracts were removed from the OpenZeppelin Contracts library on the https://forum.openzeppelin.com/t/openzeppelin-contracts-v3-0-beta-release/2256[v3.0.0 release] due to both a decline in their usage and the complexity associated with migrating them to Solidity v0.6. 4 | 5 | They are however still available on the v2.5 release of OpenZeppelin Contracts, which you can install by running: 6 | 7 | ```console 8 | $ npm install @openzeppelin/contracts@v2.5 9 | ``` 10 | 11 | Refer to the https://docs.openzeppelin.com/contracts/2.x/crowdsales[v2.x documentation] when working with them. 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/modules/ROOT/pages/drafts.adoc: -------------------------------------------------------------------------------- 1 | = Drafts 2 | 3 | All draft contracts were either moved into a different directory or removed from the OpenZeppelin Contracts library on the https://forum.openzeppelin.com/t/openzeppelin-contracts-v3-0-beta-release/2256[v3.0.0 release]. 4 | 5 | * `ERC20Migrator`: removed. 6 | * xref:api:token/ERC20.adoc#ERC20Snapshot[`ERC20Snapshot`]: moved to `token/ERC20`. 7 | * `ERC20Detailed` and `ERC1046`: removed. 8 | * `TokenVesting`: removed. Pending a replacement that is being discussed in https://github.com/OpenZeppelin/openzeppelin-contracts/issues/1214[`#1214`]. 9 | * xref:api:utils.adoc#Counters[`Counters`]: moved to xref:api:utils.adoc[`utils`]. 10 | * xref:api:utils.adoc#Strings[`Strings`]: moved to xref:api:utils.adoc[`utils`]. 11 | * xref:api:utils.adoc#SignedSafeMath[`SignedSafeMath`]: moved to xref:api:utils.adoc[`utils`]. 12 | 13 | Removed contracts are still available on the v2.5 release of OpenZeppelin Contracts, which you can install by running: 14 | 15 | ```console 16 | $ npm install @openzeppelin/contracts@v2.5 17 | ``` 18 | 19 | Refer to the xref:2.x@contracts:api:drafts.adoc[v2.x documentation] when working with them. 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/modules/ROOT/pages/wizard.adoc: -------------------------------------------------------------------------------- 1 | = Contracts Wizard 2 | :page-notoc: 3 | 4 | Not sure where to start? Use the interactive generator below to bootstrap your 5 | contract and learn about the components offered in OpenZeppelin Contracts. 6 | 7 | TIP: Place the resulting contract in your `contracts` directory in order to compile it with a tool like Hardhat or Truffle. Consider reading our guide on xref:learn::developing-smart-contracts.adoc[Developing Smart Contracts] for more guidance! 8 | 9 | ++++ 10 | 11 | 12 | 13 | ++++ 14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/docs/prelude.hbs: -------------------------------------------------------------------------------- 1 | :github-icon: pass:[] 2 | 3 | {{#links}} 4 | :{{slug target.fullName}}: pass:normal[xref:{{path}}#{{target.anchor}}[`{{target.fullName}}`]] 5 | :xref-{{slug target.anchor}}: xref:{{path}}#{{target.anchor}} 6 | {{/links}} 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/hardhat/env-contract.js: -------------------------------------------------------------------------------- 1 | extendEnvironment(env => { 2 | const { contract } = env; 3 | 4 | env.contract = function (name, body) { 5 | // remove the default account from the accounts list used in tests, in order 6 | // to protect tests against accidentally passing due to the contract 7 | // deployer being used subsequently as function caller 8 | contract(name, accounts => body(accounts.slice(1))); 9 | }; 10 | }); 11 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DominicChainsecurity/DevconVI/30da17f0f2cfa0169d87c73c7270ab70ea21855d/lib/openzeppelin-contracts/migrations/.gitkeep -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "npm run docs" 3 | publish = "build/site" 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "github>OpenZeppelin/code-style" 4 | ], 5 | "packageRules": [ 6 | { 7 | "extends": ["packages:eslint"], 8 | "enabled": false 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/gen-nav.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const path = require('path'); 4 | const proc = require('child_process'); 5 | const startCase = require('lodash.startcase'); 6 | 7 | const baseDir = process.argv[2]; 8 | 9 | const files = proc.execFileSync( 10 | 'find', [baseDir, '-type', 'f'], { encoding: 'utf8' }, 11 | ).split('\n').filter(s => s !== ''); 12 | 13 | console.log('.API'); 14 | 15 | function getPageTitle (directory) { 16 | switch (directory) { 17 | case 'metatx': 18 | return 'Meta Transactions'; 19 | case 'common': 20 | return 'Common (Tokens)'; 21 | default: 22 | return startCase(directory); 23 | } 24 | } 25 | 26 | const links = files.map((file) => { 27 | const doc = file.replace(baseDir, ''); 28 | const title = path.parse(file).name; 29 | 30 | return { 31 | xref: `* xref:${doc}[${getPageTitle(title)}]`, 32 | title, 33 | }; 34 | }); 35 | 36 | // Case-insensitive sort based on titles (so 'token/ERC20' gets sorted as 'erc20') 37 | const sortedLinks = links.sort(function (a, b) { 38 | return a.title.toLowerCase().localeCompare(b.title.toLowerCase(), undefined, { numeric: true }); 39 | }); 40 | 41 | for (const link of sortedLinks) { 42 | console.log(link.xref); 43 | } 44 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/git-user-config.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail -x 4 | 5 | git config user.name 'github-actions' 6 | git config user.email '41898282+github-actions[bot]@users.noreply.github.com' 7 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepack.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | shopt -s globstar 5 | 6 | # cross platform `mkdir -p` 7 | node -e 'fs.mkdirSync("build/contracts", { recursive: true })' 8 | 9 | cp artifacts/contracts/**/*.json build/contracts 10 | rm build/contracts/*.dbg.json 11 | 12 | node scripts/remove-ignored-artifacts.js 13 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepare-contracts-package.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # cd to the root of the repo 4 | cd "$(git rev-parse --show-toplevel)" 5 | 6 | # avoids re-compilation during publishing of both packages 7 | if [[ ! -v ALREADY_COMPILED ]]; then 8 | npm run clean 9 | npm run prepare 10 | npm run prepack 11 | fi 12 | 13 | cp README.md contracts/ 14 | mkdir contracts/build contracts/build/contracts 15 | cp -r build/contracts/*.json contracts/build/contracts 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepare-docs-solc.js: -------------------------------------------------------------------------------- 1 | const hre = require('hardhat'); 2 | 3 | const { getCompilersDir } = require('hardhat/internal/util/global-dir'); 4 | const { CompilerDownloader } = require('hardhat/internal/solidity/compiler/downloader'); 5 | const { Compiler } = require('hardhat/internal/solidity/compiler'); 6 | 7 | const [{ version }] = hre.config.solidity.compilers; 8 | 9 | async function getSolc () { 10 | const downloader = new CompilerDownloader(await getCompilersDir(), { forceSolcJs: true }); 11 | const { compilerPath } = await downloader.getDownloadedCompilerPath(version); 12 | const compiler = new Compiler(compilerPath); 13 | return compiler.getSolc(); 14 | } 15 | 16 | module.exports = Object.assign(getSolc(), { __esModule: true }); 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/prepare-docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | 5 | OUTDIR=docs/modules/api/pages/ 6 | 7 | if [ ! -d node_modules ]; then 8 | npm ci 9 | fi 10 | 11 | rm -rf "$OUTDIR" 12 | 13 | solidity-docgen \ 14 | -t docs \ 15 | -o "$OUTDIR" \ 16 | -e contracts/mocks,contracts/examples \ 17 | --output-structure readmes \ 18 | --helpers ./docs/helpers.js \ 19 | --solc-module ./scripts/prepare-docs-solc.js 20 | 21 | node scripts/gen-nav.js "$OUTDIR" > "$OUTDIR/../nav.adoc" 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/synchronize-versions.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Synchronizes the version in contracts/package.json with the one in package.json. 4 | // This is run automatically when npm version is run. 5 | 6 | const fs = require('fs'); 7 | const cp = require('child_process'); 8 | 9 | setVersion('contracts/package.json'); 10 | 11 | function setVersion (file) { 12 | const json = JSON.parse(fs.readFileSync(file)); 13 | json.version = process.env.npm_package_version; 14 | fs.writeFileSync(file, JSON.stringify(json, null, 2) + '\n'); 15 | cp.execFileSync('git', ['add', file]); 16 | } 17 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/update-changelog-release-date.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Sets the release date of the current release in the changelog. 4 | // This is run automatically when npm version is run. 5 | 6 | const fs = require('fs'); 7 | const cp = require('child_process'); 8 | 9 | const suffix = process.env.PRERELEASE_SUFFIX || 'rc'; 10 | 11 | const changelog = fs.readFileSync('CHANGELOG.md', 'utf8'); 12 | 13 | // The changelog entry to be updated looks like this: 14 | // ## Unreleased 15 | // We need to add the version and release date in a YYYY-MM-DD format, so that it looks like this: 16 | // ## 2.5.3 (2019-04-25) 17 | 18 | const pkg = require('../../package.json'); 19 | const version = pkg.version.replace(new RegExp('-' + suffix + '\\..*'), ''); 20 | 21 | const header = new RegExp(`^## (Unreleased|${version})$`, 'm'); 22 | 23 | if (!header.test(changelog)) { 24 | console.error('Missing changelog entry'); 25 | process.exit(1); 26 | } 27 | 28 | const newHeader = pkg.version.indexOf(suffix) === -1 29 | ? `## ${version} (${new Date().toISOString().split('T')[0]})` 30 | : `## ${version}`; 31 | 32 | fs.writeFileSync('CHANGELOG.md', changelog.replace(header, newHeader)); 33 | 34 | cp.execSync('git add CHANGELOG.md', { stdio: 'inherit' }); 35 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/update-comment.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const fs = require('fs'); 3 | const proc = require('child_process'); 4 | const semver = require('semver'); 5 | const run = (cmd, ...args) => proc.execFileSync(cmd, args, { encoding: 'utf8' }).trim(); 6 | 7 | const gitStatus = run('git', 'status', '--porcelain', '-uno', 'contracts/**/*.sol'); 8 | if (gitStatus.length > 0) { 9 | console.error('Contracts directory is not clean'); 10 | process.exit(1); 11 | } 12 | 13 | const { version } = require('../../package.json'); 14 | 15 | // Get latest tag according to semver. 16 | const [ tag ] = run('git', 'tag') 17 | .split(/\r?\n/) 18 | .filter(v => semver.lt(semver.coerce(v), version)) // only consider older tags, ignore current prereleases 19 | .sort(semver.rcompare); 20 | 21 | // Ordering tag → HEAD is important here. 22 | const files = run('git', 'diff', tag, 'HEAD', '--name-only', 'contracts/**/*.sol') 23 | .split(/\r?\n/) 24 | .filter(file => file && !file.match(/mock/i)); 25 | 26 | for (const file of files) { 27 | const current = fs.readFileSync(file, 'utf8'); 28 | const updated = current.replace( 29 | /(\/\/ SPDX-License-Identifier:.*)$(\n\/\/ OpenZeppelin Contracts .*$)?/m, 30 | `$1\n// OpenZeppelin Contracts (last updated v${version}) (${file.replace('contracts/', '')})`, 31 | ); 32 | fs.writeFileSync(file, updated); 33 | } 34 | 35 | run('git', 'add', '--update', 'contracts'); 36 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/release/version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -o errexit 4 | 5 | scripts/release/update-changelog-release-date.js 6 | scripts/release/synchronize-versions.js 7 | scripts/release/update-comment.js 8 | 9 | oz-docs update-version 10 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/scripts/remove-ignored-artifacts.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // This script removes the build artifacts of ignored contracts. 4 | 5 | const fs = require('fs'); 6 | const path = require('path'); 7 | const match = require('micromatch'); 8 | 9 | function readJSON (path) { 10 | return JSON.parse(fs.readFileSync(path)); 11 | } 12 | 13 | const pkgFiles = readJSON('package.json').files; 14 | 15 | // Get only negated patterns. 16 | const ignorePatterns = pkgFiles 17 | .filter(pat => pat.startsWith('!')) 18 | // Remove the negation part. Makes micromatch usage more intuitive. 19 | .map(pat => pat.slice(1)); 20 | 21 | const ignorePatternsSubtrees = ignorePatterns 22 | // Add **/* to ignore all files contained in the directories. 23 | .concat(ignorePatterns.map(pat => path.join(pat, '**/*'))) 24 | .map(p => p.replace(/^\//, '')); 25 | 26 | const artifactsDir = 'build/contracts'; 27 | const buildinfo = 'artifacts/build-info'; 28 | const filenames = fs.readdirSync(buildinfo); 29 | 30 | let n = 0; 31 | 32 | for (const filename of filenames) { 33 | const solcOutput = readJSON(path.join(buildinfo, filename)).output; 34 | for (const sourcePath in solcOutput.contracts) { 35 | const ignore = match.any(sourcePath, ignorePatternsSubtrees); 36 | if (ignore) { 37 | for (const contract in solcOutput.contracts[sourcePath]) { 38 | fs.unlinkSync(path.join(artifactsDir, contract + '.json')); 39 | n += 1; 40 | } 41 | } 42 | } 43 | } 44 | 45 | console.error(`Removed ${n} mock artifacts`); 46 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/TESTING.md: -------------------------------------------------------------------------------- 1 | ## Testing 2 | 3 | Unit test are critical to OpenZeppelin Contracts. They help ensure code quality and mitigate against security vulnerabilities. The directory structure within the `/test` directory corresponds to the `/contracts` directory. 4 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/access/AccessControl.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | shouldBehaveLikeAccessControl, 3 | } = require('./AccessControl.behavior.js'); 4 | 5 | const AccessControlMock = artifacts.require('AccessControlMock'); 6 | 7 | contract('AccessControl', function (accounts) { 8 | beforeEach(async function () { 9 | this.accessControl = await AccessControlMock.new({ from: accounts[0] }); 10 | }); 11 | 12 | shouldBehaveLikeAccessControl('AccessControl', ...accounts); 13 | }); 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/access/AccessControlEnumerable.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | shouldBehaveLikeAccessControl, 3 | shouldBehaveLikeAccessControlEnumerable, 4 | } = require('./AccessControl.behavior.js'); 5 | 6 | const AccessControlMock = artifacts.require('AccessControlEnumerableMock'); 7 | 8 | contract('AccessControl', function (accounts) { 9 | beforeEach(async function () { 10 | this.accessControl = await AccessControlMock.new({ from: accounts[0] }); 11 | }); 12 | 13 | shouldBehaveLikeAccessControl('AccessControl', ...accounts); 14 | shouldBehaveLikeAccessControlEnumerable('AccessControl', ...accounts); 15 | }); 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/eip712.js: -------------------------------------------------------------------------------- 1 | const ethSigUtil = require('eth-sig-util'); 2 | 3 | const EIP712Domain = [ 4 | { name: 'name', type: 'string' }, 5 | { name: 'version', type: 'string' }, 6 | { name: 'chainId', type: 'uint256' }, 7 | { name: 'verifyingContract', type: 'address' }, 8 | ]; 9 | 10 | async function domainSeparator (name, version, chainId, verifyingContract) { 11 | return '0x' + ethSigUtil.TypedDataUtils.hashStruct( 12 | 'EIP712Domain', 13 | { name, version, chainId, verifyingContract }, 14 | { EIP712Domain }, 15 | ).toString('hex'); 16 | } 17 | 18 | module.exports = { 19 | EIP712Domain, 20 | domainSeparator, 21 | }; 22 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/enums.js: -------------------------------------------------------------------------------- 1 | const { BN } = require('@openzeppelin/test-helpers'); 2 | 3 | function Enum (...options) { 4 | return Object.fromEntries(options.map((key, i) => [ key, new BN(i) ])); 5 | } 6 | 7 | module.exports = { 8 | Enum, 9 | ProposalState: Enum( 10 | 'Pending', 11 | 'Active', 12 | 'Canceled', 13 | 'Defeated', 14 | 'Succeeded', 15 | 'Queued', 16 | 'Expired', 17 | 'Executed', 18 | ), 19 | VoteType: Enum( 20 | 'Against', 21 | 'For', 22 | 'Abstain', 23 | ), 24 | }; 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/helpers/erc1967.js: -------------------------------------------------------------------------------- 1 | const ImplementationLabel = 'eip1967.proxy.implementation'; 2 | const AdminLabel = 'eip1967.proxy.admin'; 3 | const BeaconLabel = 'eip1967.proxy.beacon'; 4 | 5 | function labelToSlot (label) { 6 | return '0x' + web3.utils.toBN(web3.utils.keccak256(label)).subn(1).toString(16); 7 | } 8 | 9 | function getSlot (address, slot) { 10 | return web3.eth.getStorageAt( 11 | web3.utils.isAddress(address) ? address : address.address, 12 | web3.utils.isHex(slot) ? slot : labelToSlot(slot), 13 | ); 14 | } 15 | 16 | module.exports = { 17 | ImplementationLabel, 18 | AdminLabel, 19 | BeaconLabel, 20 | ImplementationSlot: labelToSlot(ImplementationLabel), 21 | AdminSlot: labelToSlot(AdminLabel), 22 | BeaconSlot: labelToSlot(BeaconLabel), 23 | getSlot, 24 | }; 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/migrate-imports.test.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const { promises: fs, constants: { F_OK } } = require('fs'); 3 | const { expect } = require('chai'); 4 | 5 | const { pathUpdates, updateImportPaths, getUpgradeablePath } = require('../scripts/migrate-imports.js'); 6 | 7 | describe('migrate-imports.js', function () { 8 | it('every new path exists', async function () { 9 | for (const p of Object.values(pathUpdates)) { 10 | try { 11 | await fs.access(path.join('contracts', p), F_OK); 12 | } catch (e) { 13 | await fs.access(path.join('contracts', getUpgradeablePath(p)), F_OK); 14 | } 15 | } 16 | }); 17 | 18 | it('replaces import paths in a file', async function () { 19 | const source = ` 20 | import '@openzeppelin/contracts/math/Math.sol'; 21 | import '@openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol'; 22 | `; 23 | const expected = ` 24 | import '@openzeppelin/contracts/utils/math/Math.sol'; 25 | import '@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol'; 26 | `; 27 | expect(updateImportPaths(source)).to.equal(expected); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/proxy/ERC1967/ERC1967Proxy.test.js: -------------------------------------------------------------------------------- 1 | const shouldBehaveLikeProxy = require('../Proxy.behaviour'); 2 | 3 | const ERC1967Proxy = artifacts.require('ERC1967Proxy'); 4 | 5 | contract('ERC1967Proxy', function (accounts) { 6 | const [proxyAdminOwner] = accounts; 7 | 8 | const createProxy = async function (implementation, _admin, initData, opts) { 9 | return ERC1967Proxy.new(implementation, initData, opts); 10 | }; 11 | 12 | shouldBehaveLikeProxy(createProxy, undefined, proxyAdminOwner); 13 | }); 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/proxy/transparent/TransparentUpgradeableProxy.test.js: -------------------------------------------------------------------------------- 1 | const shouldBehaveLikeProxy = require('../Proxy.behaviour'); 2 | const shouldBehaveLikeTransparentUpgradeableProxy = require('./TransparentUpgradeableProxy.behaviour'); 3 | 4 | const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeableProxy'); 5 | 6 | contract('TransparentUpgradeableProxy', function (accounts) { 7 | const [proxyAdminAddress, proxyAdminOwner] = accounts; 8 | 9 | const createProxy = async function (logic, admin, initData, opts) { 10 | return TransparentUpgradeableProxy.new(logic, admin, initData, opts); 11 | }; 12 | 13 | shouldBehaveLikeProxy(createProxy, proxyAdminAddress, proxyAdminOwner); 14 | shouldBehaveLikeTransparentUpgradeableProxy(createProxy, accounts); 15 | }); 16 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/security/ReentrancyGuard.test.js: -------------------------------------------------------------------------------- 1 | const { expectRevert } = require('@openzeppelin/test-helpers'); 2 | 3 | const { expect } = require('chai'); 4 | 5 | const ReentrancyMock = artifacts.require('ReentrancyMock'); 6 | const ReentrancyAttack = artifacts.require('ReentrancyAttack'); 7 | 8 | contract('ReentrancyGuard', function (accounts) { 9 | beforeEach(async function () { 10 | this.reentrancyMock = await ReentrancyMock.new(); 11 | expect(await this.reentrancyMock.counter()).to.be.bignumber.equal('0'); 12 | }); 13 | 14 | it('nonReentrant function can be called', async function () { 15 | expect(await this.reentrancyMock.counter()).to.be.bignumber.equal('0'); 16 | await this.reentrancyMock.callback(); 17 | expect(await this.reentrancyMock.counter()).to.be.bignumber.equal('1'); 18 | }); 19 | 20 | it('does not allow remote callback', async function () { 21 | const attacker = await ReentrancyAttack.new(); 22 | await expectRevert( 23 | this.reentrancyMock.countAndCall(attacker.address), 'ReentrancyAttack: failed call'); 24 | }); 25 | 26 | // The following are more side-effects than intended behavior: 27 | // I put them here as documentation, and to monitor any changes 28 | // in the side-effects. 29 | it('does not allow local recursion', async function () { 30 | await expectRevert( 31 | this.reentrancyMock.countLocalRecursive(10), 'ReentrancyGuard: reentrant call', 32 | ); 33 | }); 34 | 35 | it('does not allow indirect local recursion', async function () { 36 | await expectRevert( 37 | this.reentrancyMock.countThisRecursive(10), 'ReentrancyMock: failed call', 38 | ); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC20/extensions/ERC20Burnable.test.js: -------------------------------------------------------------------------------- 1 | const { BN } = require('@openzeppelin/test-helpers'); 2 | 3 | const { shouldBehaveLikeERC20Burnable } = require('./ERC20Burnable.behavior'); 4 | const ERC20BurnableMock = artifacts.require('ERC20BurnableMock'); 5 | 6 | contract('ERC20Burnable', function (accounts) { 7 | const [ owner, ...otherAccounts ] = accounts; 8 | 9 | const initialBalance = new BN(1000); 10 | 11 | const name = 'My Token'; 12 | const symbol = 'MTKN'; 13 | 14 | beforeEach(async function () { 15 | this.token = await ERC20BurnableMock.new(name, symbol, owner, initialBalance, { from: owner }); 16 | }); 17 | 18 | shouldBehaveLikeERC20Burnable(owner, initialBalance, otherAccounts); 19 | }); 20 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC20/extensions/ERC20Capped.behavior.js: -------------------------------------------------------------------------------- 1 | const { expectRevert } = require('@openzeppelin/test-helpers'); 2 | 3 | const { expect } = require('chai'); 4 | 5 | function shouldBehaveLikeERC20Capped (minter, [other], cap) { 6 | describe('capped token', function () { 7 | const from = minter; 8 | 9 | it('starts with the correct cap', async function () { 10 | expect(await this.token.cap()).to.be.bignumber.equal(cap); 11 | }); 12 | 13 | it('mints when amount is less than cap', async function () { 14 | await this.token.mint(other, cap.subn(1), { from }); 15 | expect(await this.token.totalSupply()).to.be.bignumber.equal(cap.subn(1)); 16 | }); 17 | 18 | it('fails to mint if the amount exceeds the cap', async function () { 19 | await this.token.mint(other, cap.subn(1), { from }); 20 | await expectRevert(this.token.mint(other, 2, { from }), 'ERC20Capped: cap exceeded'); 21 | }); 22 | 23 | it('fails to mint after cap is reached', async function () { 24 | await this.token.mint(other, cap, { from }); 25 | await expectRevert(this.token.mint(other, 1, { from }), 'ERC20Capped: cap exceeded'); 26 | }); 27 | }); 28 | } 29 | 30 | module.exports = { 31 | shouldBehaveLikeERC20Capped, 32 | }; 33 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC20/extensions/ERC20Capped.test.js: -------------------------------------------------------------------------------- 1 | const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers'); 2 | const { shouldBehaveLikeERC20Capped } = require('./ERC20Capped.behavior'); 3 | 4 | const ERC20Capped = artifacts.require('ERC20CappedMock'); 5 | 6 | contract('ERC20Capped', function (accounts) { 7 | const [ minter, ...otherAccounts ] = accounts; 8 | 9 | const cap = ether('1000'); 10 | 11 | const name = 'My Token'; 12 | const symbol = 'MTKN'; 13 | 14 | it('requires a non-zero cap', async function () { 15 | await expectRevert( 16 | ERC20Capped.new(name, symbol, new BN(0), { from: minter }), 'ERC20Capped: cap is 0', 17 | ); 18 | }); 19 | 20 | context('once deployed', async function () { 21 | beforeEach(async function () { 22 | this.token = await ERC20Capped.new(name, symbol, cap, { from: minter }); 23 | }); 24 | 25 | shouldBehaveLikeERC20Capped(minter, otherAccounts, cap); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/ERC721.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | shouldBehaveLikeERC721, 3 | shouldBehaveLikeERC721Metadata, 4 | } = require('./ERC721.behavior'); 5 | 6 | const ERC721Mock = artifacts.require('ERC721Mock'); 7 | 8 | contract('ERC721', function (accounts) { 9 | const name = 'Non Fungible Token'; 10 | const symbol = 'NFT'; 11 | 12 | beforeEach(async function () { 13 | this.token = await ERC721Mock.new(name, symbol); 14 | }); 15 | 16 | shouldBehaveLikeERC721('ERC721', ...accounts); 17 | shouldBehaveLikeERC721Metadata('ERC721', name, symbol, ...accounts); 18 | }); 19 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/ERC721Enumerable.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | shouldBehaveLikeERC721, 3 | shouldBehaveLikeERC721Metadata, 4 | shouldBehaveLikeERC721Enumerable, 5 | } = require('./ERC721.behavior'); 6 | 7 | const ERC721Mock = artifacts.require('ERC721EnumerableMock'); 8 | 9 | contract('ERC721Enumerable', function (accounts) { 10 | const name = 'Non Fungible Token'; 11 | const symbol = 'NFT'; 12 | 13 | beforeEach(async function () { 14 | this.token = await ERC721Mock.new(name, symbol); 15 | }); 16 | 17 | shouldBehaveLikeERC721('ERC721', ...accounts); 18 | shouldBehaveLikeERC721Metadata('ERC721', name, symbol, ...accounts); 19 | shouldBehaveLikeERC721Enumerable('ERC721', ...accounts); 20 | }); 21 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/extensions/ERC721Royalty.test.js: -------------------------------------------------------------------------------- 1 | const { BN, constants } = require('@openzeppelin/test-helpers'); 2 | const ERC721RoyaltyMock = artifacts.require('ERC721RoyaltyMock'); 3 | const { ZERO_ADDRESS } = constants; 4 | 5 | const { shouldBehaveLikeERC2981 } = require('../../common/ERC2981.behavior'); 6 | 7 | contract('ERC721Royalty', function (accounts) { 8 | const [ account1, account2 ] = accounts; 9 | const tokenId1 = new BN('1'); 10 | const tokenId2 = new BN('2'); 11 | const royalty = new BN('200'); 12 | const salePrice = new BN('1000'); 13 | 14 | beforeEach(async function () { 15 | this.token = await ERC721RoyaltyMock.new('My Token', 'TKN'); 16 | 17 | await this.token.mint(account1, tokenId1); 18 | await this.token.mint(account1, tokenId2); 19 | this.account1 = account1; 20 | this.account2 = account2; 21 | this.tokenId1 = tokenId1; 22 | this.tokenId2 = tokenId2; 23 | this.salePrice = salePrice; 24 | }); 25 | 26 | describe('token specific functions', function () { 27 | beforeEach(async function () { 28 | await this.token.setTokenRoyalty(tokenId1, account1, royalty); 29 | }); 30 | 31 | it('removes royalty information after burn', async function () { 32 | await this.token.burn(tokenId1); 33 | const tokenInfo = await this.token.royaltyInfo(tokenId1, salePrice); 34 | 35 | expect(tokenInfo[0]).to.be.equal(ZERO_ADDRESS); 36 | expect(tokenInfo[1]).to.be.bignumber.equal(new BN('0')); 37 | }); 38 | }); 39 | shouldBehaveLikeERC2981(); 40 | }); 41 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/token/ERC721/utils/ERC721Holder.test.js: -------------------------------------------------------------------------------- 1 | const { BN } = require('@openzeppelin/test-helpers'); 2 | 3 | const { expect } = require('chai'); 4 | 5 | const ERC721Holder = artifacts.require('ERC721Holder'); 6 | const ERC721Mock = artifacts.require('ERC721Mock'); 7 | 8 | contract('ERC721Holder', function (accounts) { 9 | const [ owner ] = accounts; 10 | 11 | const name = 'Non Fungible Token'; 12 | const symbol = 'NFT'; 13 | 14 | it('receives an ERC721 token', async function () { 15 | const token = await ERC721Mock.new(name, symbol); 16 | const tokenId = new BN(1); 17 | await token.mint(owner, tokenId); 18 | 19 | const receiver = await ERC721Holder.new(); 20 | await token.safeTransferFrom(owner, receiver.address, tokenId, { from: owner }); 21 | 22 | expect(await token.ownerOf(tokenId)).to.be.equal(receiver.address); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/Base64.test.js: -------------------------------------------------------------------------------- 1 | const { expect } = require('chai'); 2 | 3 | const Base64Mock = artifacts.require('Base64Mock'); 4 | 5 | contract('Strings', function () { 6 | beforeEach(async function () { 7 | this.base64 = await Base64Mock.new(); 8 | }); 9 | 10 | describe('from bytes - base64', function () { 11 | it('converts to base64 encoded string with double padding', async function () { 12 | const TEST_MESSAGE = 'test'; 13 | const input = web3.utils.asciiToHex(TEST_MESSAGE); 14 | expect(await this.base64.encode(input)).to.equal('dGVzdA=='); 15 | }); 16 | 17 | it('converts to base64 encoded string with single padding', async function () { 18 | const TEST_MESSAGE = 'test1'; 19 | const input = web3.utils.asciiToHex(TEST_MESSAGE); 20 | expect(await this.base64.encode(input)).to.equal('dGVzdDE='); 21 | }); 22 | 23 | it('converts to base64 encoded string without padding', async function () { 24 | const TEST_MESSAGE = 'test12'; 25 | const input = web3.utils.asciiToHex(TEST_MESSAGE); 26 | expect(await this.base64.encode(input)).to.equal('dGVzdDEy'); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/Context.test.js: -------------------------------------------------------------------------------- 1 | require('@openzeppelin/test-helpers'); 2 | 3 | const ContextMock = artifacts.require('ContextMock'); 4 | const ContextMockCaller = artifacts.require('ContextMockCaller'); 5 | 6 | const { shouldBehaveLikeRegularContext } = require('./Context.behavior'); 7 | 8 | contract('Context', function (accounts) { 9 | const [ sender ] = accounts; 10 | 11 | beforeEach(async function () { 12 | this.context = await ContextMock.new(); 13 | this.caller = await ContextMockCaller.new(); 14 | }); 15 | 16 | shouldBehaveLikeRegularContext(sender); 17 | }); 18 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/escrow/ConditionalEscrow.test.js: -------------------------------------------------------------------------------- 1 | const { ether, expectRevert } = require('@openzeppelin/test-helpers'); 2 | const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); 3 | 4 | const ConditionalEscrowMock = artifacts.require('ConditionalEscrowMock'); 5 | 6 | contract('ConditionalEscrow', function (accounts) { 7 | const [ owner, payee, ...otherAccounts ] = accounts; 8 | 9 | beforeEach(async function () { 10 | this.escrow = await ConditionalEscrowMock.new({ from: owner }); 11 | }); 12 | 13 | context('when withdrawal is allowed', function () { 14 | beforeEach(async function () { 15 | await Promise.all(otherAccounts.map(payee => this.escrow.setAllowed(payee, true))); 16 | }); 17 | 18 | shouldBehaveLikeEscrow(owner, otherAccounts); 19 | }); 20 | 21 | context('when withdrawal is disallowed', function () { 22 | const amount = ether('23'); 23 | 24 | beforeEach(async function () { 25 | await this.escrow.setAllowed(payee, false); 26 | }); 27 | 28 | it('reverts on withdrawals', async function () { 29 | await this.escrow.deposit(payee, { from: owner, value: amount }); 30 | 31 | await expectRevert(this.escrow.withdraw(payee, { from: owner }), 32 | 'ConditionalEscrow: payee is not allowed to withdraw', 33 | ); 34 | }); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/escrow/Escrow.test.js: -------------------------------------------------------------------------------- 1 | require('@openzeppelin/test-helpers'); 2 | const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); 3 | 4 | const Escrow = artifacts.require('Escrow'); 5 | 6 | contract('Escrow', function (accounts) { 7 | const [ owner, ...otherAccounts ] = accounts; 8 | 9 | beforeEach(async function () { 10 | this.escrow = await Escrow.new({ from: owner }); 11 | }); 12 | 13 | shouldBehaveLikeEscrow(owner, otherAccounts); 14 | }); 15 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/introspection/ERC165.test.js: -------------------------------------------------------------------------------- 1 | const { shouldSupportInterfaces } = require('./SupportsInterface.behavior'); 2 | 3 | const ERC165Mock = artifacts.require('ERC165Mock'); 4 | 5 | contract('ERC165', function (accounts) { 6 | beforeEach(async function () { 7 | this.mock = await ERC165Mock.new(); 8 | }); 9 | 10 | shouldSupportInterfaces([ 11 | 'ERC165', 12 | ]); 13 | }); 14 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/introspection/ERC165Storage.test.js: -------------------------------------------------------------------------------- 1 | const { expectRevert } = require('@openzeppelin/test-helpers'); 2 | 3 | const { shouldSupportInterfaces } = require('./SupportsInterface.behavior'); 4 | 5 | const ERC165Mock = artifacts.require('ERC165StorageMock'); 6 | 7 | contract('ERC165Storage', function (accounts) { 8 | beforeEach(async function () { 9 | this.mock = await ERC165Mock.new(); 10 | }); 11 | 12 | it('register interface', async function () { 13 | expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(false); 14 | await this.mock.registerInterface('0x00000001'); 15 | expect(await this.mock.supportsInterface('0x00000001')).to.be.equal(true); 16 | }); 17 | 18 | it('does not allow 0xffffffff', async function () { 19 | await expectRevert(this.mock.registerInterface('0xffffffff'), 'ERC165: invalid interface id'); 20 | }); 21 | 22 | shouldSupportInterfaces([ 23 | 'ERC165', 24 | ]); 25 | }); 26 | -------------------------------------------------------------------------------- /lib/openzeppelin-contracts/test/utils/structs/EnumerableSet.test.js: -------------------------------------------------------------------------------- 1 | const { BN } = require('@openzeppelin/test-helpers'); 2 | 3 | const EnumerableBytes32SetMock = artifacts.require('EnumerableBytes32SetMock'); 4 | const EnumerableAddressSetMock = artifacts.require('EnumerableAddressSetMock'); 5 | const EnumerableUintSetMock = artifacts.require('EnumerableUintSetMock'); 6 | 7 | const { shouldBehaveLikeSet } = require('./EnumerableSet.behavior'); 8 | 9 | contract('EnumerableSet', function (accounts) { 10 | // Bytes32Set 11 | describe('EnumerableBytes32Set', function () { 12 | const bytesA = '0xdeadbeef'.padEnd(66, '0'); 13 | const bytesB = '0x0123456789'.padEnd(66, '0'); 14 | const bytesC = '0x42424242'.padEnd(66, '0'); 15 | 16 | beforeEach(async function () { 17 | this.set = await EnumerableBytes32SetMock.new(); 18 | }); 19 | 20 | shouldBehaveLikeSet(bytesA, bytesB, bytesC); 21 | }); 22 | 23 | // AddressSet 24 | describe('EnumerableAddressSet', function () { 25 | const [accountA, accountB, accountC] = accounts; 26 | 27 | beforeEach(async function () { 28 | this.set = await EnumerableAddressSetMock.new(); 29 | }); 30 | 31 | shouldBehaveLikeSet(accountA, accountB, accountC); 32 | }); 33 | 34 | // UintSet 35 | describe('EnumerableUintSet', function () { 36 | const uintA = new BN('1234'); 37 | const uintB = new BN('5678'); 38 | const uintC = new BN('9101112'); 39 | 40 | beforeEach(async function () { 41 | this.set = await EnumerableUintSetMock.new(); 42 | }); 43 | 44 | shouldBehaveLikeSet(uintA, uintB, uintC); 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /remappings.txt: -------------------------------------------------------------------------------- 1 | test=test 2 | interfaces=interfaces 3 | -------------------------------------------------------------------------------- /src/adapters/Synthetix.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.13; 2 | 3 | 4 | import "../../interfaces/ISynthetix.sol"; 5 | 6 | interface ISynthetixAdapter { 7 | function exchange( 8 | string memory sourceCurrency, 9 | uint sourceAmount, 10 | string memory destinationCurrency 11 | ) external returns (uint amountReceived); 12 | 13 | function stringToBytes32(string memory source) external pure returns (bytes32 result); 14 | } 15 | 16 | contract SynthetixAdapter is ISynthetixAdapter { 17 | 18 | ISynthetix private immutable synthetix; 19 | //mapping(string => bool) tokenExist; 20 | address constant SYNTHETIX = 0x08F30Ecf2C15A783083ab9D5b9211c22388d0564; 21 | error NonExistingToken(); 22 | 23 | constructor() public { 24 | synthetix = ISynthetix(SYNTHETIX); 25 | } 26 | 27 | function stringToBytes32(string memory source) public pure returns (bytes32 result) { 28 | bytes memory tempEmptyStringTest = bytes(source); 29 | if (tempEmptyStringTest.length == 0) { 30 | return 0x0; 31 | } 32 | 33 | assembly { 34 | result := mload(add(source, 32)) 35 | } 36 | } 37 | 38 | function exchange( 39 | string memory sourceCurrency, 40 | uint sourceAmount, 41 | string memory destinationCurrency 42 | ) external returns (uint amountReceived) { 43 | 44 | bytes32 sourceCurrencyKey = stringToBytes32(sourceCurrency); 45 | bytes32 destinationCurrencyKey = stringToBytes32(destinationCurrency); 46 | 47 | return synthetix.exchange(sourceCurrencyKey, sourceAmount, destinationCurrencyKey); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/adapters/UniswapV3.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.13; 2 | 3 | import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; 4 | import "../../interfaces/IUniswapV3SwapRouter.sol"; 5 | import {console} from "forge-std/console.sol"; 6 | 7 | contract UniswapV3Adapter{ 8 | 9 | address private immutable UNISWAP_V3_ROUTER; 10 | 11 | constructor(address _router) public { 12 | UNISWAP_V3_ROUTER = _router; 13 | } 14 | 15 | 16 | function swap( 17 | address[] memory path, 18 | uint24[] memory fees, 19 | uint256 spentAmount, 20 | uint256 slippage 21 | ) external { 22 | ERC20 outgoingToken = ERC20(path[0]); 23 | ERC20 incomingToken = ERC20(path[path.length - 1]); 24 | outgoingToken.approve(UNISWAP_V3_ROUTER, spentAmount); 25 | 26 | bytes memory encodedPath; 27 | 28 | for (uint256 i; i < path.length; i++) { 29 | if (i != path.length - 1) { 30 | encodedPath = abi.encodePacked(encodedPath, path[i], fees[i]); 31 | } else { 32 | encodedPath = abi.encodePacked(encodedPath, path[i]); 33 | } 34 | } 35 | 36 | IUniswapV3SwapRouter.ExactInputParams memory input = IUniswapV3SwapRouter 37 | .ExactInputParams({ 38 | path: encodedPath, 39 | recipient: msg.sender, 40 | deadline: block.timestamp, 41 | amountIn: spentAmount, 42 | amountOutMinimum: slippage 43 | }); 44 | 45 | uint ret = IUniswapV3SwapRouter(UNISWAP_V3_ROUTER).exactInput(input); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /test/HelloFork.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity 0.8.13; 3 | 4 | import "interfaces/IWETH.sol"; 5 | import "src/Fund.sol"; 6 | import "forge-std/Test.sol"; 7 | import {console} from "forge-std/console.sol"; 8 | 9 | 10 | // A simple fuzzing test to detect non-zero deposit fee 11 | contract HelloForkTest is Test { 12 | 13 | address VITALIK = 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045; 14 | 15 | function testFork() public { 16 | console.log(VITALIK.balance); 17 | } 18 | } 19 | --------------------------------------------------------------------------------